cmd/compile: get rid of Fields in types.Interface, use allMethods in types.Type instead

Confusingly, the set of all methods of an interface is currently set in
Fields field of types.Interface. This is true, even though there is
already an allMethods field (and AllMethods method) of types.Type.
Change so the set of all methods of an interface are stored in
Type.allMethods, and Interface.Fields is removed. Update the comments
for Methods and AllMethods.

Change-Id: Ibc32bafae86831cba62606b079a855690612c759
Reviewed-on: https://go-review.googlesource.com/c/go/+/307209
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Dan Scales 2021-04-02 16:52:58 -07:00
parent 6ed045b365
commit a4b8241d97
12 changed files with 74 additions and 47 deletions

View file

@ -625,9 +625,9 @@ func (subst *subster) tinter(t *types.Type) *types.Type {
for i, f := range t.Methods().Slice() {
t2 := subst.typ(f.Type)
if (t2 != f.Type || f.Nname != nil) && newfields == nil {
newfields = make([]*types.Field, t.NumFields())
newfields = make([]*types.Field, t.Methods().Len())
for j := 0; j < i; j++ {
newfields[j] = t.Methods().Slice()[j]
newfields[j] = t.Methods().Index(j)
}
}
if newfields != nil {