diff options
author | Robert Findley <rfindley@google.com> | 2022-05-07 19:26:35 -0400 |
---|---|---|
committer | Robert Findley <rfindley@google.com> | 2022-06-06 15:21:40 +0000 |
commit | 02e69cfa9695f17902ff1806205c26a0d02a684f (patch) | |
tree | 80e2f4cfbc99e6a2823e7a7bebe82c4d394bcfb9 /src/cmd/compile/internal/types2/predicates.go | |
parent | 1323b0e8f0c5afb72afe51d8ee3bd5f66c23e353 (diff) | |
download | go-02e69cfa9695f17902ff1806205c26a0d02a684f.tar.gz go-02e69cfa9695f17902ff1806205c26a0d02a684f.zip |
go/types, types2: store Named instance information separately
Separate instance information into an instance struct, to reduce memory
footprint for non-instance Named types. This may induce a sense of
deja-vu: we had a similar construct in the past that was removed as
unnecessary. With additional new fields being added that only apply to
instances, having a separate struct makes sense again.
Updates #52728
Change-Id: I0bb5982d71c27e6b574bfb4f7b886a6aeb9c5390
Reviewed-on: https://go-review.googlesource.com/c/go/+/404884
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/predicates.go')
-rw-r--r-- | src/cmd/compile/internal/types2/predicates.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 6bce26137e..6b6c21c780 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -102,7 +102,7 @@ func isTypeParam(t Type) bool { func isGeneric(t Type) bool { // A parameterized type is only generic if it doesn't have an instantiation already. named, _ := t.(*Named) - return named != nil && named.obj != nil && named.targs == nil && named.TypeParams() != nil + return named != nil && named.obj != nil && named.inst == nil && named.TypeParams().Len() > 0 } // Comparable reports whether values of type T are comparable. @@ -401,7 +401,7 @@ func identical(x, y Type, cmpTags bool, p *ifacePair) bool { if len(xargs) > 0 { // Instances are identical if their original type and type arguments // are identical. - if !Identical(x.orig, y.orig) { + if !Identical(x.Origin(), y.Origin()) { return false } for i, xa := range xargs { |