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 { func needWrapType(typ types.Type) bool {
switch typ.(type) { switch typ.(type) {
case *types.Basic:
return false
case *types.Struct: case *types.Struct:
return true return true
case *types.Named: case *types.Named:
switch typ.Underlying().(type) { switch ut := typ.Underlying().(type) {
case *types.Struct: case *types.Basic:
return true return false
default:
return needWrapType(ut)
} }
case *types.Array: case *types.Array:
return true return true
case *types.Slice: case *types.Slice:
return true return true
case *types.Interface: case *types.Interface:
wrap := true
if typ.Underlying() == universe.syms["error"].GoType().Underlying() {
wrap = false
}
return wrap
case *types.Signature:
return true return true
} }
return false return false