go/types, types2: ensure we have a fully resolved type in validType

This addresses a situation where Named.fromRHS is nil which
is causing validType to panic when the debug flag is set.

Change-Id: Ie1af3f4d412efc2ce2ee7707af5375ed130a1f2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393436
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2022-03-16 14:09:56 -07:00
parent 5df3f491ac
commit 7751883379
2 changed files with 4 additions and 3 deletions

View file

@ -63,7 +63,8 @@ func (check *Checker) validType0(typ Type, env *tparamEnv, path []Object) typeIn
case *Named:
// Don't report a 2nd error if we already know the type is invalid
// (e.g., if a cycle was detected earlier, via under).
if t.underlying == Typ[Invalid] {
// Note: ensure that t.orig is fully resolved by calling Underlying().
if t.Underlying() == Typ[Invalid] {
check.infoMap[t] = invalid
return invalid
}

View file

@ -62,8 +62,8 @@ func (check *Checker) validType0(typ Type, env *tparamEnv, path []Object) typeIn
case *Named:
// Don't report a 2nd error if we already know the type is invalid
// (e.g., if a cycle was detected earlier, via under).
if t.underlying == Typ[Invalid] {
// Note: ensure that t.orig is fully resolved by calling Underlying().
if t.Underlying() == Typ[Invalid] {
check.infoMap[t] = invalid
return invalid
}