// assignableTo reports whether x is assignable to a variable of type T. If the
// result is false and a non-nil reason is provided, it may be set to a more
-// detailed explanation of the failure (result != ""). The check parameter may
-// be nil if assignableTo is invoked through an exported API call, i.e., when
-// all methods have been type-checked.
+// detailed explanation of the failure (result != ""). The returned error code
+// is only valid if the (first) result is false. The check parameter may be nil
+// if assignableTo is invoked through an exported API call, i.e., when all
+// methods have been type-checked.
func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, errorCode) {
if x.mode == invalid || T == Typ[Invalid] {
return true, 0 // avoid spurious errors
// and at least one of V or T is not a named type
if Vc, ok := Vu.(*Chan); ok && Vc.dir == SendRecv {
if Tc, ok := Tu.(*Chan); ok && check.identical(Vc.elem, Tc.elem) {
- if !isNamed(V) || !isNamed(T) {
- return true, 0
- } else {
- return false, _InvalidChanAssign
- }
+ return !isNamed(V) || !isNamed(T), _InvalidChanAssign
}
}