aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/expr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-02-17 16:04:59 -0800
committerRobert Griesemer <gri@golang.org>2021-02-18 20:47:07 +0000
commit5e4da8670b13370392a9195930e3b4bbe5f1944f (patch)
tree8ba0d44ed463401d3976f9cd3ae6047645e04340 /src/cmd/compile/internal/types2/expr.go
parent5ecb9a788716be799d73c5d8192368ecb9557d48 (diff)
downloadgo-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/expr.go')
-rw-r--r--src/cmd/compile/internal/types2/expr.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go
index 9889e3113d..07b23c9eff 100644
--- a/src/cmd/compile/internal/types2/expr.go
+++ b/src/cmd/compile/internal/types2/expr.go
@@ -110,7 +110,7 @@ func (check *Checker) overflow(x *operand) {
// Typed constants must be representable in
// their type after each constant operation.
if isTyped(x.typ) {
- check.representable(x, x.typ.Basic())
+ check.representable(x, asBasic(x.typ))
return
}
@@ -173,7 +173,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
return
case syntax.Recv:
- typ := x.typ.Chan()
+ typ := asChan(x.typ)
if typ == nil {
check.invalidOpf(x, "cannot receive from non-channel %s", x)
x.mode = invalid
@@ -543,7 +543,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) {
// If the new type is not final and still untyped, just
// update the recorded type.
if !final && isUntyped(typ) {
- old.typ = typ.Basic()
+ old.typ = asBasic(typ)
check.untyped[x] = old
return
}
@@ -1396,7 +1396,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
duplicate := false
// if the key is of interface type, the type is also significant when checking for duplicates
xkey := keyVal(x.val)
- if utyp.key.Interface() != nil {
+ if asInterface(utyp.key) != nil {
for _, vtyp := range visited[xkey] {
if check.identical(vtyp, x.typ) {
duplicate = true
@@ -1465,7 +1465,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
}
if x.mode == value {
- if sig := x.typ.Signature(); sig != nil && len(sig.tparams) > 0 {
+ if sig := asSignature(x.typ); sig != nil && len(sig.tparams) > 0 {
// function instantiation
check.funcInst(x, e)
return expression
@@ -1498,7 +1498,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
x.typ = typ.elem
case *Pointer:
- if typ := typ.base.Array(); typ != nil {
+ if typ := asArray(typ.base); typ != nil {
valid = true
length = typ.len
x.mode = variable
@@ -1536,7 +1536,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
case *Array:
e = t.elem
case *Pointer:
- if t := t.base.Array(); t != nil {
+ if t := asArray(t.base); t != nil {
e = t.elem
}
case *Slice:
@@ -1665,7 +1665,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
x.typ = &Slice{elem: typ.elem}
case *Pointer:
- if typ := typ.base.Array(); typ != nil {
+ if typ := asArray(typ.base); typ != nil {
valid = true
length = typ.len
x.typ = &Slice{elem: typ.elem}
@@ -1797,7 +1797,7 @@ func (check *Checker) exprInternal(x *operand, e syntax.Expr, hint Type) exprKin
case typexpr:
x.typ = &Pointer{base: x.typ}
default:
- if typ := x.typ.Pointer(); typ != nil {
+ if typ := asPointer(x.typ); typ != nil {
x.mode = variable
x.typ = typ.base
} else {