diff options
author | Robert Griesemer <gri@golang.org> | 2021-07-02 18:12:02 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-07-07 23:42:29 +0000 |
commit | 18135150b0ce945735d242eb6259ffc9b5c767d0 (patch) | |
tree | 49e225267b7cb510e993142cfc650c7a87ad31e2 /src/cmd/compile/internal/types2/type.go | |
parent | d2bf94fb86b45609564919caa21c6b098b5197d3 (diff) | |
download | go-18135150b0ce945735d242eb6259ffc9b5c767d0.tar.gz go-18135150b0ce945735d242eb6259ffc9b5c767d0.zip |
[dev.typeparams] cmd/compile/internal/types2: don't permit method calls on ptr to type parameter receivers
Simplify the implementation of asInterface while at it.
For #47031.
Change-Id: Ie7d4fbbab898d961ed3c0b7772ba9604641be13f
Reviewed-on: https://go-review.googlesource.com/c/go/+/332609
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/type.go')
-rw-r--r-- | src/cmd/compile/internal/types2/type.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go index e3f63f63b5..c2da97605b 100644 --- a/src/cmd/compile/internal/types2/type.go +++ b/src/cmd/compile/internal/types2/type.go @@ -112,11 +112,6 @@ func asSignature(t Type) *Signature { return op } -func asInterface(t Type) *Interface { - op, _ := optype(t).(*Interface) - return op -} - func asMap(t Type) *Map { op, _ := optype(t).(*Map) return op @@ -127,10 +122,16 @@ func asChan(t Type) *Chan { return op } -// If the argument to asNamed and asTypeParam is of the respective types +// If the argument to asInterface, asNamed, or asTypeParam is of the respective type // (possibly after expanding an instance type), these methods return that type. // Otherwise the result is nil. +// asInterface does not need to look at optype (type sets don't contain interfaces) +func asInterface(t Type) *Interface { + u, _ := under(t).(*Interface) + return u +} + func asNamed(t Type) *Named { e, _ := expand(t).(*Named) return e |