Skip to content

Commit a277bcb

Browse files
authored
Merge pull request #17941 from owen-mc/go/fix/missing-method-qualified-names
Go: fix missing qualified names for some promoted methods
2 parents fed240a + 0b24235 commit a277bcb

20 files changed

+153
-13
lines changed

go/extractor/extractor.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -1713,13 +1713,24 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
17131713
extractMethod(tw, meth)
17141714
}
17151715

1716+
underlyingInterface, underlyingIsInterface := underlying.(*types.Interface)
1717+
_, underlyingIsPointer := underlying.(*types.Pointer)
1718+
17161719
// associate all methods of underlying interface with this type
1717-
if underlyingInterface, ok := underlying.(*types.Interface); ok {
1720+
if underlyingIsInterface {
17181721
for i := 0; i < underlyingInterface.NumMethods(); i++ {
17191722
methlbl := extractMethod(tw, underlyingInterface.Method(i).Origin())
17201723
dbscheme.MethodHostsTable.Emit(tw, methlbl, lbl)
17211724
}
17221725
}
1726+
1727+
// If `underlying` is not a pointer or interface then methods can
1728+
// be defined on `origintp`. In this case we must ensure that
1729+
// `*origintp` is in the database, so that Method.hasQualifiedName
1730+
// correctly includes methods with receiver type `*origintp`.
1731+
if !underlyingIsInterface && !underlyingIsPointer {
1732+
extractType(tw, types.NewPointer(origintp))
1733+
}
17231734
case *types.TypeParam:
17241735
kind = dbscheme.TypeParamType.Index()
17251736
parentlbl := getTypeParamParentLabel(tw, tp)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* Fixed a bug which meant that some qualified names for promoted methods were not being recognised in some very specific circumstances.

go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
| pkg1/embedding.go:28:24:28:31 | embedder | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
3333
| pkg1/embedding.go:36:2:36:5 | base | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
3434
| pkg1/embedding.go:37:2:37:2 | f | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
35+
| pkg1/promotedStructs.go:5:2:5:7 | SField | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
36+
| pkg1/promotedStructs.go:14:2:14:7 | PField | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
37+
| pkg1/promotedStructs.go:22:22:22:22 | S | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
38+
| pkg1/promotedStructs.go:25:22:25:22 | P | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
3539
| pkg1/tst.go:4:2:4:2 | f | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
3640
| pkg1/tst.go:5:2:5:4 | Foo | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |
3741
| pkg1/tst.go:6:2:6:4 | Bar | package github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 |

go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
| pkg1/embedding.go:28:24:28:31 | embedder | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.embedder3 | embedder |
4444
| pkg1/embedding.go:36:2:36:5 | base | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.embedder4 | base |
4545
| pkg1/embedding.go:37:2:37:2 | f | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.embedder4 | f |
46+
| pkg1/promotedStructs.go:5:2:5:7 | SField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.S | SField |
47+
| pkg1/promotedStructs.go:5:2:5:7 | SField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedS | SField |
48+
| pkg1/promotedStructs.go:14:2:14:7 | PField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.P | PField |
49+
| pkg1/promotedStructs.go:14:2:14:7 | PField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedP | PField |
50+
| pkg1/promotedStructs.go:22:22:22:22 | S | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedS | S |
51+
| pkg1/promotedStructs.go:25:22:25:22 | P | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedP | P |
4652
| pkg1/tst.go:4:2:4:2 | f | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T | f |
4753
| pkg1/tst.go:5:2:5:4 | Foo | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T | Foo |
4854
| pkg1/tst.go:6:2:6:4 | Bar | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T | Bar |

go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
| pkg1/embedding.go:28:24:28:31 | embedder | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | embedder3 | embedder |
4444
| pkg1/embedding.go:36:2:36:5 | base | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | embedder4 | base |
4545
| pkg1/embedding.go:37:2:37:2 | f | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | embedder4 | f |
46+
| pkg1/promotedStructs.go:5:2:5:7 | SField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | S | SField |
47+
| pkg1/promotedStructs.go:5:2:5:7 | SField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedS | SField |
48+
| pkg1/promotedStructs.go:14:2:14:7 | PField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | P | PField |
49+
| pkg1/promotedStructs.go:14:2:14:7 | PField | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedP | PField |
50+
| pkg1/promotedStructs.go:22:22:22:22 | S | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedS | S |
51+
| pkg1/promotedStructs.go:25:22:25:22 | P | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedP | P |
4652
| pkg1/tst.go:4:2:4:2 | f | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T | f |
4753
| pkg1/tst.go:5:2:5:4 | Foo | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T | Foo |
4854
| pkg1/tst.go:6:2:6:4 | Bar | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T | Bar |

go/ql/test/library-tests/semmle/go/Types/MethodCount.expected

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
| * Foo | 1 |
2+
| * P | 1 |
3+
| * S | 1 |
4+
| * SEmbedP | 1 |
5+
| * SEmbedS | 1 |
6+
| * T | 1 |
7+
| * T3 | 1 |
8+
| * T4 | 1 |
29
| * base | 2 |
310
| * embedder | 2 |
411
| * embedder2 | 2 |
@@ -16,6 +23,8 @@
1623
| GenericInterface | 1 |
1724
| MixedExportedAndNot | 2 |
1825
| MyInterface | 17 |
26+
| S | 1 |
27+
| SEmbedS | 1 |
1928
| T | 1 |
2029
| T3 | 1 |
2130
| T4 | 1 |

go/ql/test/library-tests/semmle/go/Types/MethodTypes.expected

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
| pkg1/interfaces.go:31:6:31:7 | A2 | m | func() |
5151
| pkg1/interfaces.go:35:6:35:24 | MixedExportedAndNot | Exported | func() |
5252
| pkg1/interfaces.go:35:6:35:24 | MixedExportedAndNot | notExported | func() |
53+
| pkg1/promotedStructs.go:22:6:22:12 | SEmbedS | SMethod | func() interface { } |
5354
| pkg1/tst.go:3:6:3:6 | T | half | func() Foo |
5455
| pkg1/tst.go:14:6:14:7 | T3 | half | func() Foo |
5556
| pkg1/tst.go:19:6:19:7 | T4 | half | func() Foo |

go/ql/test/library-tests/semmle/go/Types/Method_hasQualifiedName2.expected

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
| pkg1/interfaces.go:32:2:32:2 | m | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.A2 | m |
5656
| pkg1/interfaces.go:36:2:36:9 | Exported | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.MixedExportedAndNot | Exported |
5757
| pkg1/interfaces.go:37:2:37:12 | notExported | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.MixedExportedAndNot | notExported |
58+
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.S | SMethod |
59+
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedS | SMethod |
60+
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.P | PMethod |
61+
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedP | PMethod |
5862
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.Foo | half |
5963
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T | half |
6064
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T3 | half |

go/ql/test/library-tests/semmle/go/Types/Method_hasQualifiedName3.expected

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
| pkg1/interfaces.go:32:2:32:2 | m | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | A2 | m |
5656
| pkg1/interfaces.go:36:2:36:9 | Exported | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | MixedExportedAndNot | Exported |
5757
| pkg1/interfaces.go:37:2:37:12 | notExported | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | MixedExportedAndNot | notExported |
58+
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | S | SMethod |
59+
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedS | SMethod |
60+
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | P | PMethod |
61+
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedP | PMethod |
5862
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | Foo | half |
5963
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T | half |
6064
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T3 | half |

go/ql/test/library-tests/semmle/go/Types/Methods.expected

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
| * Foo | half | pkg1/tst.go:33:16:33:19 | half |
2+
| * P | PMethod | pkg1/promotedStructs.go:17:13:17:19 | PMethod |
3+
| * S | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
4+
| * SEmbedP | PMethod | pkg1/promotedStructs.go:17:13:17:19 | PMethod |
5+
| * SEmbedS | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
6+
| * T | half | pkg1/tst.go:33:16:33:19 | half |
7+
| * T3 | half | pkg1/tst.go:33:16:33:19 | half |
8+
| * T4 | half | pkg1/tst.go:33:16:33:19 | half |
29
| * base | f | pkg1/embedding.go:10:13:10:13 | f |
310
| * base | g | pkg1/embedding.go:14:14:14:14 | g |
411
| * embedder | f | pkg1/embedding.go:10:13:10:13 | f |
@@ -45,6 +52,8 @@
4552
| MyInterface | dummy18 | generic.go:62:2:62:8 | dummy18 |
4653
| MyInterface | dummy19 | generic.go:63:2:63:8 | dummy19 |
4754
| MyInterface | dummy20 | generic.go:64:2:64:8 | dummy20 |
55+
| S | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
56+
| SEmbedS | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
4857
| T | half | pkg1/tst.go:33:16:33:19 | half |
4958
| T3 | half | pkg1/tst.go:33:16:33:19 | half |
5059
| T4 | half | pkg1/tst.go:33:16:33:19 | half |

go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
| pkg1/interfaces.go:26:6:26:14 | AExtended | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.AExtended |
9292
| pkg1/interfaces.go:31:6:31:7 | A2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.A2 |
9393
| pkg1/interfaces.go:35:6:35:24 | MixedExportedAndNot | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.MixedExportedAndNot |
94+
| pkg1/promotedStructs.go:4:6:4:6 | S | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.S |
95+
| pkg1/promotedStructs.go:13:6:13:6 | P | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.P |
96+
| pkg1/promotedStructs.go:22:6:22:12 | SEmbedS | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedS |
97+
| pkg1/promotedStructs.go:25:6:25:12 | SEmbedP | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedP |
9498
| pkg1/tst.go:3:6:3:6 | T | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T |
9599
| pkg1/tst.go:9:6:9:7 | T2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T2 |
96100
| pkg1/tst.go:14:6:14:7 | T3 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T3 |

go/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected

+6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
| pkg1/embedding.go:14:1:16:1 | function declaration | 0 |
1212
| pkg1/embedding.go:30:1:32:1 | function declaration | 0 |
1313
| pkg1/embedding.go:40:1:61:1 | function declaration | 0 |
14+
| pkg1/promotedStructs.go:8:1:10:1 | function declaration | 0 |
15+
| pkg1/promotedStructs.go:17:1:19:1 | function declaration | 0 |
1416
| pkg1/tst.go:33:1:35:1 | function declaration | 0 |
1517
| pkg1/tst.go:37:1:37:26 | function declaration | 1 |
1618
| pkg1/tst.go:39:1:57:1 | function declaration | 2 |
19+
| promoted.go:7:1:10:1 | function declaration | 1 |
20+
| promoted.go:12:1:15:1 | function declaration | 1 |
21+
| promoted.go:17:1:20:1 | function declaration | 1 |
22+
| promoted.go:22:1:25:1 | function declaration | 1 |
1723
| unknownFunction.go:8:1:12:1 | function declaration | 0 |
1824
| variadicFunctions.go:5:1:8:1 | function declaration | 0 |
1925
| variadicFunctions.go:10:1:18:1 | function declaration | 1 |

go/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected

+6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
| pkg1/embedding.go:14:1:16:1 | function declaration | 1 |
1212
| pkg1/embedding.go:30:1:32:1 | function declaration | 1 |
1313
| pkg1/embedding.go:40:1:61:1 | function declaration | 0 |
14+
| pkg1/promotedStructs.go:8:1:10:1 | function declaration | 1 |
15+
| pkg1/promotedStructs.go:17:1:19:1 | function declaration | 1 |
1416
| pkg1/tst.go:33:1:35:1 | function declaration | 1 |
1517
| pkg1/tst.go:37:1:37:26 | function declaration | 0 |
1618
| pkg1/tst.go:39:1:57:1 | function declaration | 0 |
19+
| promoted.go:7:1:10:1 | function declaration | 0 |
20+
| promoted.go:12:1:15:1 | function declaration | 0 |
21+
| promoted.go:17:1:20:1 | function declaration | 0 |
22+
| promoted.go:22:1:25:1 | function declaration | 0 |
1723
| unknownFunction.go:8:1:12:1 | function declaration | 0 |
1824
| variadicFunctions.go:5:1:8:1 | function declaration | 0 |
1925
| variadicFunctions.go:10:1:18:1 | function declaration | 1 |

go/ql/test/library-tests/semmle/go/Types/StructFields.expected

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
| pkg1/embedding.go:28:6:28:14 | embedder3 | pkg1/embedding.go:28:16:28:33 | struct type | embedder | embedder |
4646
| pkg1/embedding.go:35:6:35:14 | embedder4 | pkg1/embedding.go:35:16:38:1 | struct type | base | base |
4747
| pkg1/embedding.go:35:6:35:14 | embedder4 | pkg1/embedding.go:35:16:38:1 | struct type | f | int |
48+
| pkg1/promotedStructs.go:4:6:4:6 | S | pkg1/promotedStructs.go:4:8:6:1 | struct type | SField | string |
49+
| pkg1/promotedStructs.go:13:6:13:6 | P | pkg1/promotedStructs.go:13:8:15:1 | struct type | PField | string |
50+
| pkg1/promotedStructs.go:22:6:22:12 | SEmbedS | pkg1/promotedStructs.go:22:14:22:24 | struct type | S | S |
51+
| pkg1/promotedStructs.go:22:6:22:12 | SEmbedS | pkg1/promotedStructs.go:22:14:22:24 | struct type | SField | string |
52+
| pkg1/promotedStructs.go:25:6:25:12 | SEmbedP | pkg1/promotedStructs.go:25:14:25:24 | struct type | P | P |
53+
| pkg1/promotedStructs.go:25:6:25:12 | SEmbedP | pkg1/promotedStructs.go:25:14:25:24 | struct type | PField | string |
4854
| pkg1/tst.go:3:6:3:6 | T | pkg1/tst.go:3:8:7:1 | struct type | Bar | Bar |
4955
| pkg1/tst.go:3:6:3:6 | T | pkg1/tst.go:3:8:7:1 | struct type | Foo | Foo |
5056
| pkg1/tst.go:3:6:3:6 | T | pkg1/tst.go:3:8:7:1 | struct type | f | int |

go/ql/test/library-tests/semmle/go/Types/Types.expected

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
| pkg1/interfaces.go:26:6:26:14 | AExtended | AExtended |
9292
| pkg1/interfaces.go:31:6:31:7 | A2 | A2 |
9393
| pkg1/interfaces.go:35:6:35:24 | MixedExportedAndNot | MixedExportedAndNot |
94+
| pkg1/promotedStructs.go:4:6:4:6 | S | S |
95+
| pkg1/promotedStructs.go:13:6:13:6 | P | P |
96+
| pkg1/promotedStructs.go:22:6:22:12 | SEmbedS | SEmbedS |
97+
| pkg1/promotedStructs.go:25:6:25:12 | SEmbedP | SEmbedP |
9498
| pkg1/tst.go:3:6:3:6 | T | T |
9599
| pkg1/tst.go:9:6:9:7 | T2 | T2 |
96100
| pkg1/tst.go:14:6:14:7 | T3 | T3 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package pkg1
2+
3+
// A struct type with methods defined on it
4+
type S struct {
5+
SField string
6+
}
7+
8+
func (t S) SMethod() interface{} {
9+
return nil
10+
}
11+
12+
// A struct type with methods defined on its pointer type
13+
type P struct {
14+
PField string
15+
}
16+
17+
func (t *P) PMethod() interface{} {
18+
return nil
19+
}
20+
21+
// A struct type embedding S
22+
type SEmbedS struct{ S }
23+
24+
// A struct type embedding P
25+
type SEmbedP struct{ P }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import "github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1"
4+
5+
// IMPORTANT: Make sure that *pkg1.SEmbedP is not referenced.
6+
7+
func testS(t pkg1.S) {
8+
_ = t.SMethod()
9+
_ = t.SField
10+
}
11+
12+
func testP(t pkg1.P) {
13+
_ = t.PMethod()
14+
_ = t.PField
15+
}
16+
17+
func testSEmbedS(t pkg1.SEmbedS) {
18+
_ = t.SMethod()
19+
_ = t.SField
20+
}
21+
22+
func testSEmbedP(t pkg1.SEmbedP) {
23+
_ = t.PMethod()
24+
_ = t.PField
25+
}

go/ql/test/library-tests/semmle/go/aliases/InterfaceImpls/test.expected

+13-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ callTargets
1313
| test.go:57:2:57:29 | call to ImplementMe | test.go:46:1:46:87 | function declaration | ImplementMe |
1414
| test.go:57:2:57:29 | call to ImplementMe | test.go:53:1:53:85 | function declaration | ImplementMe |
1515
#select
16-
| file://:0:0:0:0 | basic interface type | file://:0:0:0:0 | basic interface type |
17-
| file://:0:0:0:0 | basic interface type | test.go:18:6:18:10 | Impl1 |
18-
| file://:0:0:0:0 | basic interface type | test.go:23:6:23:10 | Impl2 |
19-
| file://:0:0:0:0 | basic interface type | test.go:28:6:28:10 | Impl3 |
20-
| file://:0:0:0:0 | basic interface type | test.go:35:6:35:10 | Impl4 |
21-
| file://:0:0:0:0 | basic interface type | test.go:42:6:42:10 | Impl5 |
22-
| file://:0:0:0:0 | basic interface type | test.go:49:6:49:10 | Impl6 |
16+
| file://:0:0:0:0 | basic interface type | * Impl1 |
17+
| file://:0:0:0:0 | basic interface type | * Impl2 |
18+
| file://:0:0:0:0 | basic interface type | * Impl3 |
19+
| file://:0:0:0:0 | basic interface type | * Impl4 |
20+
| file://:0:0:0:0 | basic interface type | * Impl5 |
21+
| file://:0:0:0:0 | basic interface type | * Impl6 |
22+
| file://:0:0:0:0 | basic interface type | Impl1 |
23+
| file://:0:0:0:0 | basic interface type | Impl2 |
24+
| file://:0:0:0:0 | basic interface type | Impl3 |
25+
| file://:0:0:0:0 | basic interface type | Impl4 |
26+
| file://:0:0:0:0 | basic interface type | Impl5 |
27+
| file://:0:0:0:0 | basic interface type | Impl6 |
28+
| file://:0:0:0:0 | basic interface type | interface { ImplementMe func(func(struct { x int }) ) } |

go/ql/test/library-tests/semmle/go/aliases/InterfaceImpls/test.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ from InterfaceType i, Type impl
88
where
99
i.hasMethod("ImplementMe", _) and
1010
impl.implements(i)
11-
select i, impl
11+
select i, impl.pp()

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ func TestI2(t test.I2) {
1919
func TestS1(t test.S1) {
2020
x := t.Source()
2121
y := t.Step(x)
22-
t.Sink(y) // $ I1[t] S1[f] S1[t] ql_S1 SPURIOUS: IEmbedI1[t] SEmbedI1[t]
22+
t.Sink(y) // $ I1[t] S1[f] S1[t] ql_S1 SPURIOUS: IEmbedI1[t] SEmbedI1[t] SEmbedS1[t]
2323
}
2424

2525
func TestS2(t test.S2) {
2626
x := t.Source()
2727
y := t.Step(x)
28-
t.Sink(y) // $ I1[t] I2[t] SPURIOUS: IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
28+
t.Sink(y) // $ I1[t] I2[t] SPURIOUS: IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t] SEmbedS2[t]
2929
}
3030

3131
func TestSEmbedI1(t test.SEmbedI1) {
@@ -67,13 +67,13 @@ func TestSImplEmbedI2(t test.SImplEmbedI2) {
6767
func TestSEmbedS1(t test.SEmbedS1) {
6868
x := t.Source()
6969
y := t.Step(x)
70-
t.Sink(y) // $ I1[t] S1[t] ql_S1 SPURIOUS: IEmbedI1[t] S1[f] SEmbedI1[t]
70+
t.Sink(y) // $ I1[t] S1[t] SEmbedS1[t] ql_S1 SPURIOUS: IEmbedI1[t] S1[f] SEmbedI1[t]
7171
}
7272

7373
func TestSEmbedS2(t test.SEmbedS2) {
7474
x := t.Source()
7575
y := t.Step(x)
76-
t.Sink(y) // $ I1[t] I2[t] SPURIOUS: IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
76+
t.Sink(y) // $ I1[t] I2[t] SEmbedS2[t] SPURIOUS: IEmbedI1[t] IEmbedI2[t] SEmbedI1[t] SEmbedI2[t]
7777
}
7878

7979
func TestSImplEmbedS1(t test.SImplEmbedS1) {

0 commit comments

Comments
 (0)