diff options
author | Robert Griesemer <gri@golang.org> | 2021-06-28 17:21:26 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-06-30 18:59:58 +0000 |
commit | f0206e3df2f134cb1a13402aefbb6caeec4fc126 (patch) | |
tree | 3f064621a62e4c5590d054ca1421819655fdf27a /src/cmd/compile/internal/types2/type.go | |
parent | 1ff43d1b179eb96a34b9007e10d78e2278643f3f (diff) | |
download | go-f0206e3df2f134cb1a13402aefbb6caeec4fc126.tar.gz go-f0206e3df2f134cb1a13402aefbb6caeec4fc126.zip |
[dev.typeparams] cmd/compile/internal/types2: move embedding positions from Checker to Interface
This change moves the position information to the place where it
is actually used. It also simplifies getting rid of it after use.
In the process, fixed a latent bug: Before this CL, embedded types
were sorted, but the corresponding embedding positions were not.
Removed the sorting altogether as it is not needed for type-checking.
Change-Id: I48003f317196d814326424430336b6cb222fdee6
Reviewed-on: https://go-review.googlesource.com/c/go/+/331514
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/type.go')
-rw-r--r-- | src/cmd/compile/internal/types2/type.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index 122e408ead..2cfcabbdb5 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -264,10 +264,11 @@ func (s *Signature) Variadic() bool { return s.variadic } // An Interface represents an interface type. type Interface struct { - obj Object // type name object defining this interface; or nil (for better error messages) - methods []*Func // ordered list of explicitly declared methods - embeddeds []Type // ordered list of explicitly embedded elements - complete bool // indicates that obj, methods, and embeddeds are set and type set can be computed + obj Object // type name object defining this interface; or nil (for better error messages) + methods []*Func // ordered list of explicitly declared methods + embeddeds []Type // ordered list of explicitly embedded elements + embedPos *[]syntax.Pos // positions of embedded elements; or nil (for error messages) - use pointer to save space + complete bool // indicates that all fields (except for tset) are set up tset *TypeSet // type set described by this interface, computed lazily } @@ -322,7 +323,6 @@ func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface { // sort for API stability sortMethods(methods) - sortTypes(embeddeds) typ.methods = methods typ.embeddeds = embeddeds |