Skip to content

Commit

Permalink
Resolves infinite recursion issue in named types
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Moran committed May 28, 2019
1 parent ec46ade commit c1bd10a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions rendering/named_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion rendering/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit c1bd10a

Please sign in to comment.