diff options
author | Robert Griesemer <gri@golang.org> | 2023-08-24 09:07:03 -0700 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-08-30 15:45:21 +0000 |
commit | 2fa7129836d65a3c44696747cc2cd9e9f391c66f (patch) | |
tree | 578708aa683e98c338d0f8235078064cccd1c4f0 /src/cmd/compile/internal/types2/predicates.go | |
parent | 0e02baa59af2e8e3e26702bd8ebe72ae5a0e39c7 (diff) | |
download | go-2fa7129836d65a3c44696747cc2cd9e9f391c66f.tar.gz go-2fa7129836d65a3c44696747cc2cd9e9f391c66f.zip |
go/types, types2: use asNamed(t) instead of t.(*Named) type assertions
Preparation for the introduction of alias types.
Because asNamed is not exported, existing external
tests continue to use t.(*Named).
Change-Id: I4754b406dd6b23030d3703a486d6f6620b2464fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/522876
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: 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 075bd97d0f..872b874ecb 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -124,7 +124,7 @@ func hasEmptyTypeset(t Type) bool { // TODO(gri) should we include signatures or assert that they are not present? func isGeneric(t Type) bool { // A parameterized type is only generic if it doesn't have an instantiation already. - named, _ := t.(*Named) + named := asNamed(t) return named != nil && named.obj != nil && named.inst == nil && named.TypeParams().Len() > 0 } @@ -435,7 +435,7 @@ func (c *comparer) identical(x, y Type, p *ifacePair) bool { // Two named types are identical if their type names originate // in the same type declaration; if they are instantiated they // must have identical type argument lists. - if y, ok := y.(*Named); ok { + if y := asNamed(y); y != nil { // check type arguments before origins to match unifier // (for correct source code we need to do all checks so // order doesn't matter) |