Skip to content

Commit

Permalink
support types.Alias
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Aug 20, 2024
1 parent 910874a commit 66dba08
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,17 @@ func (g *Generator) renderType(ctx context.Context, typ types.Type) string {
args = append(args, g.renderType(ctx, arg))
}
return fmt.Sprintf("%s[%s]", name, strings.Join(args, ","))
case *types.Alias:
name := g.getPackageScopedType(ctx, t.Obj())
if t.TypeArgs() == nil || t.TypeArgs().Len() == 0 {
return name
}
args := make([]string, 0, t.TypeArgs().Len())
for i := 0; i < t.TypeArgs().Len(); i++ {
arg := t.TypeArgs().At(i)
args = append(args, g.renderType(ctx, arg))
}
return fmt.Sprintf("%s[%s]", name, strings.Join(args, ","))
case *types.TypeParam:
if t.Constraint() != nil {
name := t.Obj().Name()
Expand Down

0 comments on commit 66dba08

Please sign in to comment.