Skip to content

Commit

Permalink
#648: fix invalid code generation when interface method parameter's n…
Browse files Browse the repository at this point in the history
…ame is the same as interface name
  • Loading branch information
kozmod committed Jun 25, 2023
1 parent 78f7ac3 commit b92d507
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ func (g *Generator) mockName() string {
}

// getTypeConstraintString returns type constraint string for a given interface.
// For instance, a method using this constraint:
//
// func Foo[T Stringer](s []T) (ret []string) {
//
// }
// For instance, a method using this constraint:
// func Foo[T Stringer](s []T) (ret []string) {
// }
//
// The constraint returned will be "[T Stringer]"
//
Expand Down Expand Up @@ -495,7 +494,10 @@ func (g *Generator) genList(ctx context.Context, list *types.Tuple, variadic boo
}
}

pname := v.Name()
pname := v.Name()x
if ts == pname {
pname = fmt.Sprintf("%s%d", pname, i)
}

if g.nameCollides(pname) || pname == "" {
pname = fmt.Sprintf("_a%d", i)
Expand Down

0 comments on commit b92d507

Please sign in to comment.