x.mode = invalid
return
}
- target = defaultType(x.typ)
+ target = Default(x.typ)
}
check.convertUntyped(x, target)
if x.mode == invalid {
lhs.typ = Typ[Invalid]
return nil
}
- typ = defaultType(typ)
+ typ = Default(typ)
}
lhs.typ = typ
}
func makeSig(res Type, args ...Type) *Signature {
list := make([]*Var, len(args))
for i, param := range args {
- list[i] = NewVar(token.NoPos, nil, "", defaultType(param))
+ list[i] = NewVar(token.NoPos, nil, "", Default(param))
}
params := NewTuple(list...)
var result *Tuple
// not []byte as type for the constant "foo").
// - Keep untyped nil for untyped nil arguments.
if IsInterface(T) || constArg && !isConstType(T) {
- final = defaultType(x.typ)
+ final = Default(x.typ)
}
check.updateExprType(x.expr, final, true)
}
if !t.Empty() {
goto Error
}
- target = defaultType(x.typ)
+ target = Default(x.typ)
}
case *Pointer, *Signature, *Slice, *Map, *Chan:
if !x.isNil() {
// time will be materialized. Update the expression trees.
// If the current types are untyped, the materialized type
// is the respective default type.
- check.updateExprType(x.expr, defaultType(x.typ), true)
- check.updateExprType(y.expr, defaultType(y.typ), true)
+ check.updateExprType(x.expr, Default(x.typ), true)
+ check.updateExprType(y.expr, Default(y.typ), true)
}
// spec: "Comparison operators compare two operands and yield
return false
}
-// defaultType returns the default "typed" type for an "untyped" type;
+// Default returns the default "typed" type for an "untyped" type;
// it returns the incoming type for all other types. The default type
// for untyped nil is untyped nil.
//
-func defaultType(typ Type) Type {
+func Default(typ Type) Type {
if t, ok := typ.(*Basic); ok {
switch t.kind {
case UntypedBool: