diff options
author | Robert Griesemer <gri@golang.org> | 2021-02-17 17:56:34 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-02-18 20:47:17 +0000 |
commit | 099374b55e8aed17d1e77a1084f8fb78ff2f8162 (patch) | |
tree | a93d6b9f5cd0c51a25b3072cddba372c85c850c0 /src/cmd/compile/internal/types2/subst.go | |
parent | 653386a89a702b54bb01be893cfd30cddb0e6107 (diff) | |
download | go-099374b55e8aed17d1e77a1084f8fb78ff2f8162.tar.gz go-099374b55e8aed17d1e77a1084f8fb78ff2f8162.zip |
[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 <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/subst.go')
-rw-r--r-- | src/cmd/compile/internal/types2/subst.go | 6 |
1 files changed, 3 insertions, 3 deletions
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 } } |