From c1bd10adfb7c5136f6e1e74c5b9d1abbc1e443e9 Mon Sep 17 00:00:00 2001 From: Ryan Moran Date: Tue, 28 May 2019 11:49:12 -0400 Subject: [PATCH] Resolves infinite recursion issue in named types --- rendering/named_type.go | 7 +++++++ rendering/type.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rendering/named_type.go b/rendering/named_type.go index ece6c90..1b2e404 100644 --- a/rendering/named_type.go +++ b/rendering/named_type.go @@ -17,6 +17,13 @@ func NewNamedType(name string, t Type) NamedType { } } +func NewDefinedType(name string) NamedType { + return NamedType{ + Name: name, + Type: Interface{}, + } +} + func (nt NamedType) Expr() ast.Expr { return ast.NewIdent(nt.Name) } diff --git a/rendering/type.go b/rendering/type.go index 1100fac..89a1873 100644 --- a/rendering/type.go +++ b/rendering/type.go @@ -27,7 +27,7 @@ func NewType(t types.Type) Type { name = fmt.Sprintf("%s.%s", pkg.Name(), obj.Name()) } - return NewNamedType(name, NewType(t.Underlying())) + return NewDefinedType(name) case *types.Interface: return Interface{}