Skip to content

Commit fd8d99d

Browse files
authored
fix (1217): getting parameter type names panics in presence of generic types (#1218)
1 parent a34327e commit fd8d99d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

internal/astutils/ast_utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ func getFieldTypeName(typ ast.Expr) string {
7171
return f.Sel.Name + "." + getFieldTypeName(f.X)
7272
case *ast.StarExpr:
7373
return "*" + getFieldTypeName(f.X)
74+
case *ast.IndexExpr:
75+
return getFieldTypeName(f.X) + "[" + getFieldTypeName(f.Index) + "]"
7476
default:
7577
panic(fmt.Sprintf("not supported type %T", typ))
7678
}

testdata/golint/sort.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ func (vv Vv) Less(i int, j int) (result bool) { return w[i] < w[j] } // MATCH /e
4141
type X []int
4242

4343
func (x X) Less(i *pkg.tip) (result bool) { return len(x) } // MATCH /exported method X.Less should have comment or be unexported/
44+
45+
// Test for issue #1217
46+
func (s *synchronized[T]) Swap(other Synchronized[T]) {}

0 commit comments

Comments
 (0)