bind: needWrapType - preliminary support for interfaces+namedtypes

Change-Id: Ia4ef5bcf3ef36eecb02cd63e5beadc1177ef1484
This commit is contained in:
Sebastien Binet 2015-08-07 13:43:07 +02:00
parent 47aa4f07a5
commit 93b3f8f979
1 changed files with 13 additions and 3 deletions

View File

@ -22,18 +22,28 @@ type Type interface {
func needWrapType(typ types.Type) bool {
switch typ.(type) {
case *types.Basic:
return false
case *types.Struct:
return true
case *types.Named:
switch typ.Underlying().(type) {
case *types.Struct:
return true
switch ut := typ.Underlying().(type) {
case *types.Basic:
return false
default:
return needWrapType(ut)
}
case *types.Array:
return true
case *types.Slice:
return true
case *types.Interface:
wrap := true
if typ.Underlying() == universe.syms["error"].GoType().Underlying() {
wrap = false
}
return wrap
case *types.Signature:
return true
}
return false