aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/builtins.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/types2/builtins.go')
-rw-r--r--src/cmd/compile/internal/types2/builtins.go29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go
index bd1ea0fdc1..a6a9b51dd1 100644
--- a/src/cmd/compile/internal/types2/builtins.go
+++ b/src/cmd/compile/internal/types2/builtins.go
@@ -1,4 +1,3 @@
-// UNREVIEWED
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -83,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)
@@ -143,7 +142,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
mode := invalid
var typ Type
var val constant.Value
- switch typ = implicitArrayDeref(optype(x.typ.Under())); t := typ.(type) {
+ switch typ = implicitArrayDeref(optype(x.typ)); t := typ.(type) {
case *Basic:
if isString(t) && id == _Len {
if x.mode == constant_ {
@@ -179,7 +178,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
case *Sum:
if t.is(func(t Type) bool {
- switch t := t.Under().(type) {
+ switch t := under(t).(type) {
case *Basic:
if isString(t) && id == _Len {
return true
@@ -211,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
@@ -287,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]
@@ -321,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
}
@@ -331,7 +330,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
var src Type
- switch t := optype(y.typ.Under()).(type) {
+ switch t := optype(y.typ).(type) {
case *Basic:
if isString(y.typ) {
src = universeByte
@@ -358,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
@@ -405,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]
@@ -454,7 +453,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
var valid func(t Type) bool
valid = func(t Type) bool {
var m int
- switch t := optype(t.Under()).(type) {
+ switch t := optype(t).(type) {
case *Slice:
m = 2
case *Map, *Chan:
@@ -578,7 +577,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
case _Alignof:
// unsafe.Alignof(x T) uintptr
- if x.typ.TypeParam() != nil {
+ if asTypeParam(x.typ) != nil {
check.invalidOpf(call, "unsafe.Alignof undefined for %s", x)
return
}
@@ -639,7 +638,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
case _Sizeof:
// unsafe.Sizeof(x T) uintptr
- if x.typ.TypeParam() != nil {
+ if asTypeParam(x.typ) != nil {
check.invalidOpf(call, "unsafe.Sizeof undefined for %s", x)
return
}
@@ -706,7 +705,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// applyTypeFunc returns nil.
// If x is not a type parameter, the result is f(x).
func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type {
- if tp := x.TypeParam(); tp != nil {
+ if tp := asTypeParam(x); tp != nil {
// Test if t satisfies the requirements for the argument
// type and collect possible result types at the same time.
var rtypes []Type
@@ -758,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
}
}