Skip to content

Commit 84c4174

Browse files
committed
Include type parameter's index in its label
1 parent 9aafcbc commit 84c4174

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

go/extractor/extractor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,8 @@ func getTypeLabel(tw *trap.Writer, tp types.Type) (trap.Label, bool) {
17761776
lbl = tw.Labeler.GlobalID(fmt.Sprintf("{%s};namedtype", entitylbl))
17771777
case *types.TypeParam:
17781778
parentlbl := getTypeParamParentLabel(tw, tp)
1779-
lbl = tw.Labeler.GlobalID(fmt.Sprintf("{%v},%s;typeparamtype", parentlbl, tp.Obj().Name()))
1779+
idx := tp.Index()
1780+
lbl = tw.Labeler.GlobalID(fmt.Sprintf("{%v},%d,%s;typeparamtype", parentlbl, idx, tp.Obj().Name()))
17801781
case *types.Union:
17811782
var b strings.Builder
17821783
for i := 0; i < tp.Len(); i++ {

go/ql/test/library-tests/semmle/go/Function/TypeParamType.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ numberOfTypeParameters
1616
| genericFunctions.go:132:6:132:10 | Graph | 2 |
1717
| genericFunctions.go:134:6:134:8 | New | 2 |
1818
| genericFunctions.go:138:29:138:40 | ShortestPath | 2 |
19-
| genericFunctions.go:150:6:150:36 | multipleAnonymousTypeParamsFunc | 1 |
20-
| genericFunctions.go:152:6:152:36 | multipleAnonymousTypeParamsType | 1 |
21-
| genericFunctions.go:154:51:154:51 | f | 1 |
19+
| genericFunctions.go:150:6:150:36 | multipleAnonymousTypeParamsFunc | 3 |
20+
| genericFunctions.go:152:6:152:36 | multipleAnonymousTypeParamsType | 3 |
21+
| genericFunctions.go:154:51:154:51 | f | 3 |
2222
#select
2323
| cmp.Compare | 0 | T | Ordered |
2424
| cmp.Less | 0 | T | Ordered |

0 commit comments

Comments
 (0)