aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/decl.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2021-07-21 12:12:22 -0400
committerRobert Findley <rfindley@google.com>2021-07-28 19:15:09 +0000
commit473e493d18c277d69e40a4930af045d474ff2be4 (patch)
tree38f5d91931d924e17229c82d4152d61dc5b292a4 /src/cmd/compile/internal/types2/decl.go
parente00a6ec084605b773cdb87971de5b5536c0cc13e (diff)
downloadgo-473e493d18c277d69e40a4930af045d474ff2be4.tar.gz
go-473e493d18c277d69e40a4930af045d474ff2be4.zip
[dev.typeparams] cmd/compile/internal/types2: merge instance and Named to eliminate sanitization
This is a port of CL 335929 to types2. It differs significantly from that CL to handle lazy loading, which wasn't tested in go/types. Additionally, the *Checker field was moved out of instance and back onto Named. This way we can tell whether a Named type is uninstantiated simply by checking whether Named.instance is non-nil, which simplified the code considerably. Fixes #46151 Change-Id: I617263bcfaa768ac5442213cecad8d567c2749fc Reviewed-on: https://go-review.googlesource.com/c/go/+/336252 Trust: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/decl.go')
-rw-r--r--src/cmd/compile/internal/types2/decl.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go
index 4f656e374a..6ca8f75e9a 100644
--- a/src/cmd/compile/internal/types2/decl.go
+++ b/src/cmd/compile/internal/types2/decl.go
@@ -317,6 +317,8 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo {
}
case *Named:
+ t.expand()
+
// don't touch the type if it is from a different package or the Universe scope
// (doing so would lead to a race condition - was issue #35049)
if t.obj.pkg != check.pkg {
@@ -349,9 +351,6 @@ func (check *Checker) validType(typ Type, path []Object) typeInfo {
panic("internal error: cycle start not found")
}
return t.info
-
- case *instance:
- return check.validType(t.expand(), path)
}
return valid
@@ -557,7 +556,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
// determine underlying type of named
named.fromRHS = check.definedType(tdecl.Type, named)
-
+ assert(named.fromRHS != nil)
// The underlying type of named may be itself a named type that is
// incomplete:
//
@@ -624,7 +623,8 @@ func (check *Checker) boundType(e syntax.Expr) Type {
bound := check.typ(e)
check.later(func() {
- if _, ok := under(bound).(*Interface); !ok && bound != Typ[Invalid] {
+ u := under(bound)
+ if _, ok := u.(*Interface); !ok && u != Typ[Invalid] {
check.errorf(e, "%s is not an interface", bound)
}
})
@@ -692,7 +692,7 @@ func (check *Checker) collectMethods(obj *TypeName) {
}
if base != nil {
- base.expand() // TODO(mdempsky): Probably unnecessary.
+ base.load() // TODO(mdempsky): Probably unnecessary.
base.methods = append(base.methods, m)
}
}