aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typexpr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-02-17 17:06:53 -0800
committerRobert Griesemer <gri@golang.org>2021-02-18 20:47:11 +0000
commit653386a89a702b54bb01be893cfd30cddb0e6107 (patch)
tree8cdea0b59711b9a9377f64ae3e1117aa9eddd31d /src/cmd/compile/internal/types2/typexpr.go
parent5e4da8670b13370392a9195930e3b4bbe5f1944f (diff)
downloadgo-653386a89a702b54bb01be893cfd30cddb0e6107.tar.gz
go-653386a89a702b54bb01be893cfd30cddb0e6107.zip
[dev.typeparams] cmd/compile/internal/types2: replace Named, TypeParam methods with functions
This removes two more converter methods in favor of functions. This further reduces the API surface of types2.Type and matches the approach taken in go/types. Change-Id: I3cdd54c5e0d1e7664a69f3697fc081a66315b969 Reviewed-on: https://go-review.googlesource.com/c/go/+/293292 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/typexpr.go')
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index 7ee28abac3..cf9d7c0a40 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -302,7 +302,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
// Also: Don't report an error via genericType since it will be reported
// again when we type-check the signature.
// TODO(gri) maybe the receiver should be marked as invalid instead?
- if recv := check.genericType(rname, false).Named(); recv != nil {
+ if recv := asNamed(check.genericType(rname, false)); recv != nil {
recvTParams = recv.tparams
}
}
@@ -382,7 +382,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
// (ignore invalid types - error was reported before)
if t := rtyp; t != Typ[Invalid] {
var err string
- if T := t.Named(); T != nil {
+ if T := asNamed(t); T != nil {
// spec: "The type denoted by T is called the receiver base type; it must not
// be a pointer or interface type and it must be declared in the same package
// as the method."
@@ -575,7 +575,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) {
check.atEnd(func() {
if !Comparable(typ.key) {
var why string
- if typ.key.TypeParam() != nil {
+ if asTypeParam(typ.key) != nil {
why = " (missing comparable constraint)"
}
check.errorf(e.Key, "invalid map key type %s%s", typ.key, why)
@@ -644,7 +644,7 @@ func (check *Checker) instantiatedType(x syntax.Expr, targs []syntax.Expr, def *
if b == Typ[Invalid] {
return b // error already reported
}
- base := b.Named()
+ base := asNamed(b)
if base == nil {
unreachable() // should have been caught by genericType
}
@@ -1045,7 +1045,7 @@ func (a byUniqueTypeName) Less(i, j int) bool { return sortName(a[i]) < sortName
func (a byUniqueTypeName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func sortName(t Type) string {
- if named := t.Named(); named != nil {
+ if named := asNamed(t); named != nil {
return named.obj.Id()
}
return ""