diff options
author | Robert Griesemer <gri@golang.org> | 2021-02-17 16:04:59 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-02-18 20:47:07 +0000 |
commit | 5e4da8670b13370392a9195930e3b4bbe5f1944f (patch) | |
tree | 8ba0d44ed463401d3976f9cd3ae6047645e04340 /src/cmd/compile/internal/types2/builtins.go | |
parent | 5ecb9a788716be799d73c5d8192368ecb9557d48 (diff) | |
download | go-5e4da8670b13370392a9195930e3b4bbe5f1944f.tar.gz go-5e4da8670b13370392a9195930e3b4bbe5f1944f.zip |
[dev.typeparams] cmd/compile/internal/types2: use converter functions rather than methods
This change replaces methods with functions to reduce the API surface of
types2.Type and to match the approach taken in go/types. The converter
methods for Named and TypeParam will be addressed in a follow-up CL.
Also: Fixed behavior of optype to return the underlying type for
arguments that are not type parameters.
Change-Id: Ia369c796754bc33bbaf0c9c8478badecb729279b
Reviewed-on: https://go-review.googlesource.com/c/go/+/293291
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/builtins.go')
-rw-r--r-- | src/cmd/compile/internal/types2/builtins.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 591a22f814..763122bc5b 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -82,7 +82,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // of S and the respective parameter passing rules apply." S := x.typ var T Type - if s := S.Slice(); s != nil { + if s := asSlice(S); s != nil { T = s.elem } else { check.invalidArgf(x, "%s is not a slice", x) @@ -210,7 +210,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Close: // close(c) - c := x.typ.Chan() + c := asChan(x.typ) if c == nil { check.invalidArgf(x, "%s is not a channel", x) return @@ -286,7 +286,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // the argument types must be of floating-point type f := func(x Type) Type { - if t := x.Basic(); t != nil { + if t := asBasic(x); t != nil { switch t.kind { case Float32: return Typ[Complex64] @@ -320,7 +320,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Copy: // copy(x, y []T) int var dst Type - if t := x.typ.Slice(); t != nil { + if t := asSlice(x.typ); t != nil { dst = t.elem } @@ -357,7 +357,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Delete: // delete(m, k) - m := x.typ.Map() + m := asMap(x.typ) if m == nil { check.invalidArgf(x, "%s is not a map", x) return @@ -404,7 +404,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // the argument must be of complex type f := func(x Type) Type { - if t := x.Basic(); t != nil { + if t := asBasic(x); t != nil { switch t.kind { case Complex64: return Typ[Float32] @@ -757,7 +757,7 @@ func makeSig(res Type, args ...Type) *Signature { // func implicitArrayDeref(typ Type) Type { if p, ok := typ.(*Pointer); ok { - if a := p.base.Array(); a != nil { + if a := asArray(p.base); a != nil { return a } } |