diff options
Diffstat (limited to 'src/cmd/compile/internal/types2/builtins.go')
-rw-r--r-- | src/cmd/compile/internal/types2/builtins.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 7b2c92bfa8..c022e79c97 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -144,7 +144,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)); t := typ.(type) { + switch typ = implicitArrayDeref(under(x.typ)); t := typ.(type) { case *Basic: if isString(t) && id == _Len { if x.mode == constant_ { @@ -178,9 +178,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( mode = value } - case *Union: + case *TypeParam: if t.underIs(func(t Type) bool { - switch t := t.(type) { + switch t := implicitArrayDeref(t).(type) { case *Basic: if isString(t) && id == _Len { return true @@ -817,10 +817,10 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { // type and collect possible result types at the same time. var rtypes []Type var tildes []bool - if !tp.iface().is(func(typ Type, tilde bool) bool { - if r := f(typ); r != nil { + if !tp.iface().typeSet().is(func(t *term) bool { + if r := f(t.typ); r != nil { rtypes = append(rtypes, r) - tildes = append(tildes, tilde) + tildes = append(tildes, t.tilde) return true } return false @@ -837,10 +837,8 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type { // type param is placed in the current package so export/import // works as expected. tpar := NewTypeName(nopos, check.pkg, "<type parameter>", nil) - ptyp := check.NewTypeParam(tpar, &emptyInterface) // assigns type to tpar as a side-effect + ptyp := check.NewTypeParam(tpar, NewInterfaceType(nil, []Type{newUnion(rtypes, tildes)})) // assigns type to tpar as a side-effect ptyp.index = tp.index - tsum := newUnion(rtypes, tildes) - ptyp.bound = &Interface{complete: true, tset: &TypeSet{types: tsum}} return ptyp } |