From 099374b55e8aed17d1e77a1084f8fb78ff2f8162 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 17 Feb 2021 17:56:34 -0800 Subject: [dev.typeparams] cmd/compile/internal/types2: remove Type.Under method in favor of function This removes the need for the aType embedded type and brings the types2.Type API in sync with the go/types.Type API. For reasons not fully understood yet, introducing the new under function causes a very long initialization cycle error, which doesn't exist in go/types. For now, circumvent the problem through a helper function variable. This CL also eliminates superflous (former) Under() method calls inside optype calls (optype takes care of this). Plus some minor misc. cleanups and comment adjustments. Change-Id: I86e13ccf6f0b34d7496240ace61a1c84856b6033 Reviewed-on: https://go-review.googlesource.com/c/go/+/293470 Reviewed-by: Robert Findley Trust: Robert Griesemer --- src/cmd/compile/internal/types2/subst.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cmd/compile/internal/types2/subst.go') diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go index fc4b228e33..d730642831 100644 --- a/src/cmd/compile/internal/types2/subst.go +++ b/src/cmd/compile/internal/types2/subst.go @@ -61,7 +61,7 @@ func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, poslis check.indent-- var under Type if res != nil { - // Calling Under() here may lead to endless instantiations. + // Calling under() here may lead to endless instantiations. // Test case: type T[P any] T[P] // TODO(gri) investigate if that's a bug or to be expected. under = res.Underlying() @@ -186,7 +186,7 @@ func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, poslis break } for _, t := range unpack(targBound.allTypes) { - if !iface.isSatisfiedBy(t.Under()) { + if !iface.isSatisfiedBy(t) { // TODO(gri) match this error message with the one below (or vice versa) check.softErrorf(pos, "%s does not satisfy %s (%s type constraint %s not found in %s)", targ, tpar.bound, targ, t, iface.allTypes) break @@ -197,7 +197,7 @@ func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, poslis // Otherwise, targ's type or underlying type must also be one of the interface types listed, if any. if !iface.isSatisfiedBy(targ) { - check.softErrorf(pos, "%s does not satisfy %s (%s not found in %s)", targ, tpar.bound, targ.Under(), iface.allTypes) + check.softErrorf(pos, "%s does not satisfy %s (%s not found in %s)", targ, tpar.bound, under(targ), iface.allTypes) break } } -- cgit v1.2.3-54-g00ecf