return
}
var src Type
- switch t := optype(y.typ).(type) {
+ switch t := under(y.typ).(type) {
case *Basic:
if isString(y.typ) {
src = universeByte
}
case *Slice:
src = t.elem
+ case *TypeParam:
+ check.error(x, "copy on generic operands not yet implemented")
}
if dst == nil || src == nil {
var valid func(t Type) bool
valid = func(t Type) bool {
var m int
- switch t := optype(t).(type) {
+ switch t := under(t).(type) {
case *Slice:
m = 2
case *Map, *Chan:
m = 1
- case *Union:
+ case *TypeParam:
return t.underIs(valid)
default:
return false
return nil, nil, _InvalidUntypedConversion
}
- switch t := optype(target).(type) {
+ switch t := under(target).(type) {
case *Basic:
if x.mode == constant_ {
v, code := check.representation(x, t)
default:
return nil, nil, _InvalidUntypedConversion
}
- case *Union:
+ case *TypeParam:
ok := t.underIs(func(t Type) bool {
target, _, _ := check.implicitTypeAndValue(x, t)
return target != nil
goto Error
}
- switch utyp := optype(base).(type) {
+ switch utyp := under(base).(type) {
case *Struct:
if len(e.ElemList) == 0 {
break
}
func is(typ Type, what BasicInfo) bool {
- switch t := optype(typ).(type) {
+ switch t := under(typ).(type) {
case *Basic:
return t.info&what != 0
- case *Union:
+ case *TypeParam:
return t.underIs(func(t Type) bool { return is(t, what) })
}
return false
// are not fully set up.
func isTyped(typ Type) bool {
// isTyped is called with types that are not fully
- // set up. Must not call Basic()!
+ // set up. Must not call asBasic()!
// A *Named or *instance type is always typed, so
// we only need to check if we have a true *Basic
// type.
seen[T] = true
// If T is a type parameter not constrained by any type
- // list (i.e., it's operational type is the top type),
+ // (i.e., it's operational type is the top type),
// T is comparable if it has the == method. Otherwise,
// the operational type "wins". For instance
//
// interface{ comparable; type []byte }
//
// is not comparable because []byte is not comparable.
+ // TODO(gri) this code is not 100% correct (see comment for TypeSet.IsComparable)
if t := asTypeParam(T); t != nil && optype(t) == theTop {
return t.Bound().IsComparable()
}
- switch t := optype(T).(type) {
+ switch t := under(T).(type) {
case *Basic:
// assume invalid types to be comparable
// to avoid follow-up errors
return true
case *Array:
return comparable(t.elem, seen)
- case *Union:
+ case *TypeParam:
return t.underIs(func(t Type) bool {
return comparable(t, seen)
})
- case *TypeParam:
- return t.Bound().IsComparable()
}
return false
}
// hasNil reports whether a type includes the nil value.
func hasNil(typ Type) bool {
- switch t := optype(typ).(type) {
+ switch t := under(typ).(type) {
case *Basic:
return t.kind == UnsafePointer
case *Slice, *Pointer, *Signature, *Interface, *Map, *Chan:
return true
- case *Union:
+ case *TypeParam:
return t.underIs(hasNil)
}
return false