File tree Expand file tree Collapse file tree
go/ql/test/library-tests/semmle/go/Function Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66| genericFunctions.go:45:6:45:50 | generic function instantiation expression | genericFunctions.go:45:6:45:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:45:43:45:49 | float64 |
77| genericFunctions.go:141:6:141:41 | generic function instantiation expression | genericFunctions.go:141:6:141:33 | GenericFunctionInAnotherFile | 0 | genericFunctions.go:141:35:141:40 | string |
88| genericFunctions.go:146:6:146:55 | generic function instantiation expression | genericFunctions.go:146:6:146:47 | selection of GenericFunctionInAnotherPackage | 0 | genericFunctions.go:146:49:146:54 | string |
9+ | genericMethods.go:13:2:13:23 | generic function instantiation expression | genericMethods.go:13:2:13:18 | selection of GenericMethod1 | 0 | genericMethods.go:13:20:13:22 | int |
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ numberOfTypeParameters
1919| genericFunctions.go:150:6:150:36 | multipleAnonymousTypeParamsFunc | 3 |
2020| genericFunctions.go:152:6:152:36 | multipleAnonymousTypeParamsType | 3 |
2121| genericFunctions.go:154:51:154:51 | f | 3 |
22+ | genericMethods.go:5:33:5:46 | GenericMethod1 | 1 |
23+ | genericMethods.go:7:6:7:28 | StructForGenericMethod2 | 1 |
24+ | genericMethods.go:9:36:9:49 | GenericMethod2 | 2 |
2225#select
2326| codeql-go-tests/function.EdgeConstraint | 0 | Node | interface { } |
2427| codeql-go-tests/function.Element | 0 | S | interface { } |
@@ -44,6 +47,10 @@ numberOfTypeParameters
4447| codeql-go-tests/function.New | 0 | Node | NodeConstraint |
4548| codeql-go-tests/function.New | 1 | Edge | EdgeConstraint |
4649| codeql-go-tests/function.NodeConstraint | 0 | Edge | interface { } |
50+ | codeql-go-tests/function.StructForGenericMethod1.GenericMethod1 | 0 | P | interface { } |
51+ | codeql-go-tests/function.StructForGenericMethod2 | 0 | P | interface { } |
52+ | codeql-go-tests/function.StructForGenericMethod2.GenericMethod2 | 0 | P | interface { } |
53+ | codeql-go-tests/function.StructForGenericMethod2.GenericMethod2 | 0 | Q | interface { } |
4754| codeql-go-tests/function.multipleAnonymousTypeParamsFunc | 0 | _ | interface { } |
4855| codeql-go-tests/function.multipleAnonymousTypeParamsFunc | 1 | _ | interface { string } |
4956| codeql-go-tests/function.multipleAnonymousTypeParamsFunc | 2 | _ | interface { } |
Original file line number Diff line number Diff line change 1+ package main
2+
3+ type StructForGenericMethod1 struct {}
4+
5+ func (* StructForGenericMethod1 ) GenericMethod1 [P any ](x P ) {}
6+
7+ type StructForGenericMethod2 [P any ] struct {}
8+
9+ func (* StructForGenericMethod2 [P ]) GenericMethod2 [Q any ](x Q ) {}
10+
11+ func generic_methods (s1 StructForGenericMethod1 , s2 StructForGenericMethod2 [int ]) {
12+ // Call the generic method specifying the type
13+ s1.GenericMethod1 [int ](1 )
14+ //s2.GenericMethod2[string]("hello")
15+
16+ // Call the generic method without specifying the type
17+ s1 .GenericMethod1 ("hello" )
18+ //s2.GenericMethod2(42)
19+ }
Original file line number Diff line number Diff line change 1111| genericFunctions.go:138:29:138:40 | ShortestPath | 1 | genericFunctions.go:138:48:138:49 | to |
1212| genericFunctions.go:138:29:138:40 | ShortestPath | -1 | genericFunctions.go:138:7:138:7 | g |
1313| genericFunctions.go:154:51:154:51 | f | -1 | genericFunctions.go:154:7:154:7 | x |
14+ | genericMethods.go:5:33:5:46 | GenericMethod1 | 0 | genericMethods.go:5:55:5:55 | x |
15+ | genericMethods.go:9:36:9:49 | GenericMethod2 | 0 | genericMethods.go:9:58:9:58 | x |
16+ | genericMethods.go:11:6:11:20 | generic_methods | 0 | genericMethods.go:11:22:11:23 | s1 |
17+ | genericMethods.go:11:6:11:20 | generic_methods | 1 | genericMethods.go:11:50:11:51 | s2 |
1418| main.go:7:6:7:7 | f1 | 0 | main.go:7:9:7:9 | x |
1519| main.go:9:12:9:13 | f2 | 0 | main.go:9:15:9:15 | x |
1620| main.go:9:12:9:13 | f2 | 1 | main.go:9:18:9:18 | y |
Original file line number Diff line number Diff line change 1919| genericFunctions.go:152:6:152:69 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:152:38:152:42 | type parameter declaration | 0 | genericFunctions.go:152:38:152:38 | _ | genericFunctions.go:152:40:152:42 | any | interface { } |
2020| genericFunctions.go:152:6:152:69 | type declaration specifier | TypeSpec | 1 | genericFunctions.go:152:45:152:52 | type parameter declaration | 0 | genericFunctions.go:152:45:152:45 | _ | genericFunctions.go:152:47:152:52 | string | interface { string } |
2121| genericFunctions.go:152:6:152:69 | type declaration specifier | TypeSpec | 2 | genericFunctions.go:152:55:152:59 | type parameter declaration | 0 | genericFunctions.go:152:55:152:55 | _ | genericFunctions.go:152:57:152:59 | any | interface { } |
22+ | genericMethods.go:5:1:5:61 | function declaration | MethodDecl | 0 | genericMethods.go:5:48:5:52 | type parameter declaration | 0 | genericMethods.go:5:48:5:48 | P | genericMethods.go:5:50:5:52 | any | interface { } |
23+ | genericMethods.go:7:6:7:45 | type declaration specifier | TypeSpec | 0 | genericMethods.go:7:30:7:34 | type parameter declaration | 0 | genericMethods.go:7:30:7:30 | P | genericMethods.go:7:32:7:34 | any | interface { } |
24+ | genericMethods.go:9:1:9:65 | function declaration | MethodDecl | 0 | genericMethods.go:9:51:9:55 | type parameter declaration | 0 | genericMethods.go:9:51:9:51 | Q | genericMethods.go:9:53:9:55 | any | interface { } |
Original file line number Diff line number Diff line change 11module codeql-go-tests/function
22
3- go 1.18
3+ go 1.27
4+
5+ toolchain go1.27rc1
46
57require github.com/anotherpkg v0.0.0-20200203000000-0000000000000
68
You can’t perform that action at this time.
0 commit comments