mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Fix bug by extracting more pointer types
This commit is contained in:
@@ -1713,13 +1713,24 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
|
||||
extractMethod(tw, meth)
|
||||
}
|
||||
|
||||
underlyingInterface, underlyingIsInterface := underlying.(*types.Interface)
|
||||
_, underlyingIsPointer := underlying.(*types.Pointer)
|
||||
|
||||
// associate all methods of underlying interface with this type
|
||||
if underlyingInterface, ok := underlying.(*types.Interface); ok {
|
||||
if underlyingIsInterface {
|
||||
for i := 0; i < underlyingInterface.NumMethods(); i++ {
|
||||
methlbl := extractMethod(tw, underlyingInterface.Method(i).Origin())
|
||||
dbscheme.MethodHostsTable.Emit(tw, methlbl, lbl)
|
||||
}
|
||||
}
|
||||
|
||||
// If `underlying` is not a pointer or interface then methods can
|
||||
// be defined on `origintp`. In this case we must ensure that
|
||||
// `*origintp` is in the database, so that Method.hasQualifiedName
|
||||
// correctly includes methods with receiver type `*origintp`.
|
||||
if !underlyingIsInterface && !underlyingIsPointer {
|
||||
extractType(tw, types.NewPointer(origintp))
|
||||
}
|
||||
case *types.TypeParam:
|
||||
kind = dbscheme.TypeParamType.Index()
|
||||
parentlbl := getTypeParamParentLabel(tw, tp)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
| * Foo | 1 |
|
||||
| * P | 1 |
|
||||
| * S | 1 |
|
||||
| * SEmbedP | 1 |
|
||||
| * SEmbedS | 1 |
|
||||
| * T | 1 |
|
||||
| * T3 | 1 |
|
||||
| * T4 | 1 |
|
||||
| * base | 2 |
|
||||
| * embedder | 2 |
|
||||
| * embedder2 | 2 |
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.S | SMethod |
|
||||
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedS | SMethod |
|
||||
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.P | PMethod |
|
||||
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.SEmbedP | PMethod |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.Foo | half |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T | half |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1.T3 | half |
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | S | SMethod |
|
||||
| pkg1/promotedStructs.go:8:12:8:18 | SMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedS | SMethod |
|
||||
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | P | PMethod |
|
||||
| pkg1/promotedStructs.go:17:13:17:19 | PMethod | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | SEmbedP | PMethod |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | Foo | half |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T | half |
|
||||
| pkg1/tst.go:33:16:33:19 | half | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types/pkg1 | T3 | half |
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
| * Foo | half | pkg1/tst.go:33:16:33:19 | half |
|
||||
| * P | PMethod | pkg1/promotedStructs.go:17:13:17:19 | PMethod |
|
||||
| * S | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
|
||||
| * SEmbedP | PMethod | pkg1/promotedStructs.go:17:13:17:19 | PMethod |
|
||||
| * SEmbedS | SMethod | pkg1/promotedStructs.go:8:12:8:18 | SMethod |
|
||||
| * T | half | pkg1/tst.go:33:16:33:19 | half |
|
||||
| * T3 | half | pkg1/tst.go:33:16:33:19 | half |
|
||||
| * T4 | half | pkg1/tst.go:33:16:33:19 | half |
|
||||
| * base | f | pkg1/embedding.go:10:13:10:13 | f |
|
||||
| * base | g | pkg1/embedding.go:14:14:14:14 | g |
|
||||
| * embedder | f | pkg1/embedding.go:10:13:10:13 | f |
|
||||
|
||||
Reference in New Issue
Block a user