From 93b3f8f979e3bd6315df66ec8e12b1c53b628cf6 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Fri, 7 Aug 2015 13:43:07 +0200 Subject: [PATCH] bind: needWrapType - preliminary support for interfaces+namedtypes Change-Id: Ia4ef5bcf3ef36eecb02cd63e5beadc1177ef1484 --- bind/types.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bind/types.go b/bind/types.go index 5b0a85b..aab36ad 100644 --- a/bind/types.go +++ b/bind/types.go @@ -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