Simplify convertible check - same type is OK

This is to clarify the code.  No actual effect at the moment, but I manually
verified this in the case of identical types.
This commit is contained in:
Tim Hockin 2016-06-25 01:59:34 +09:00
parent ed59210f04
commit 7fa1e87d66

View File

@ -309,6 +309,9 @@ func isDirectlyConvertible(in, out *types.Type, manualConversions conversionFunc
return isConvertible(in, out.Underlying, manualConversions)
}
if in == out {
return true
}
if in.Kind != out.Kind {
return false
}
@ -318,12 +321,6 @@ func isDirectlyConvertible(in, out *types.Type, manualConversions conversionFunc
// We don't support conversion of other types yet.
return false
}
switch out.Kind {
case types.Builtin, types.Struct, types.Map, types.Slice, types.Pointer:
default:
// We don't support conversion of other types yet.
return false
}
switch in.Kind {
case types.Builtin: