diff --git a/go/extractor/extractor.go b/go/extractor/extractor.go index c0eef233ba583..8b52be4553e37 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -475,12 +475,12 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label) populateTypeParamParents(funcObj.Type().(*types.Signature).TypeParams(), obj) populateTypeParamParents(funcObj.Type().(*types.Signature).RecvTypeParams(), obj) } - // Populate type parameter parents for named types. Note that we - // skip type aliases as the original type should be the parent - // of any type parameters. - if typeNameObj, ok := obj.(*types.TypeName); ok && !typeNameObj.IsAlias() { + // Populate type parameter parents for named types. + if typeNameObj, ok := obj.(*types.TypeName); ok { if tp, ok := typeNameObj.Type().(*types.Named); ok { populateTypeParamParents(tp.TypeParams(), obj) + } else if tp, ok := typeNameObj.Type().(*types.Alias); ok { + populateTypeParamParents(tp.TypeParams(), obj) } } extractObject(tw, obj, lbl) diff --git a/go/ql/test/library-tests/semmle/go/Types/Aliases.expected b/go/ql/test/library-tests/semmle/go/Types/Aliases.expected index 2c09dd790a565..64a07bdfd9300 100644 --- a/go/ql/test/library-tests/semmle/go/Types/Aliases.expected +++ b/go/ql/test/library-tests/semmle/go/Types/Aliases.expected @@ -14,6 +14,11 @@ entities | aliases.go | aliases.go:22:6:22:6 | T | 1 | aliases.go:19:6:19:7 | S3 | | aliases.go | aliases.go:25:6:25:6 | H | 1 | file://:0:0:0:0 | signature type | | aliases.go | aliases.go:25:8:25:11 | Afs3 | 1 | aliases.go:19:6:19:7 | S3 | +| aliases.go | aliases.go:29:6:29:9 | User | 1 | aliases.go:29:6:29:9 | User | +| aliases.go | aliases.go:29:11:29:15 | UserT | 1 | file://:0:0:0:0 | type parameter type | +| aliases.go | aliases.go:29:30:29:30 | x | 1 | file://:0:0:0:0 | type parameter type | +| aliases.go | aliases.go:32:6:32:14 | UserAlias | 1 | aliases.go:29:6:29:9 | User | +| aliases.go | aliases.go:32:16:32:25 | UserAliasT | 1 | file://:0:0:0:0 | type parameter type | #select | F | func(struct { x int }) int | | G | func(struct { x int }) int | diff --git a/go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected b/go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected index 83f4093da50ef..626b194b3d637 100644 --- a/go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected +++ b/go/ql/test/library-tests/semmle/go/Types/Field_getPackage.expected @@ -1,6 +1,7 @@ | aliases.go:6:26:6:26 | x | package codeql-go-types | | aliases.go:8:26:8:26 | x | package codeql-go-types | | aliases.go:19:17:19:17 | x | package codeql-go-types | +| aliases.go:29:30:29:30 | x | package codeql-go-types | | cyclic.go:4:3:4:3 | s | package codeql-go-types | | cyclic.go:8:3:8:3 | u | package codeql-go-types | | cyclic.go:9:2:9:2 | f | package codeql-go-types | diff --git a/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected b/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected index 4c354d961d687..ac059a358a55f 100644 --- a/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected +++ b/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName2.expected @@ -1,6 +1,7 @@ | aliases.go:6:26:6:26 | x | codeql-go-types.S3 | x | | aliases.go:8:26:8:26 | x | codeql-go-types.S3 | x | | aliases.go:19:17:19:17 | x | codeql-go-types.S3 | x | +| aliases.go:29:30:29:30 | x | codeql-go-types.User | x | | cyclic.go:4:3:4:3 | s | codeql-go-types.s | s | | cyclic.go:8:3:8:3 | u | codeql-go-types.t | u | | cyclic.go:8:3:8:3 | u | codeql-go-types.u | u | diff --git a/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected b/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected index 0e4ba3035e89f..2055e864b4307 100644 --- a/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected +++ b/go/ql/test/library-tests/semmle/go/Types/Field_hasQualifiedName3.expected @@ -1,6 +1,7 @@ | aliases.go:6:26:6:26 | x | codeql-go-types | S3 | x | | aliases.go:8:26:8:26 | x | codeql-go-types | S3 | x | | aliases.go:19:17:19:17 | x | codeql-go-types | S3 | x | +| aliases.go:29:30:29:30 | x | codeql-go-types | User | x | | cyclic.go:4:3:4:3 | s | codeql-go-types | s | s | | cyclic.go:8:3:8:3 | u | codeql-go-types | t | u | | cyclic.go:8:3:8:3 | u | codeql-go-types | u | u | diff --git a/go/ql/test/library-tests/semmle/go/Types/GenericTypeInstantiationExpr.expected b/go/ql/test/library-tests/semmle/go/Types/GenericTypeInstantiationExpr.expected index a6941dc84a2a6..aba8309a3d77e 100644 --- a/go/ql/test/library-tests/semmle/go/Types/GenericTypeInstantiationExpr.expected +++ b/go/ql/test/library-tests/semmle/go/Types/GenericTypeInstantiationExpr.expected @@ -1,3 +1,4 @@ +| aliases.go:32:34:32:49 | generic type instantiation expression | aliases.go:32:34:32:37 | User | 0 | aliases.go:32:39:32:48 | UserAliasT | | generic.go:12:16:12:40 | generic type instantiation expression | generic.go:12:16:12:37 | CircularGenericStruct1 | 0 | generic.go:12:39:12:39 | T | | generic.go:16:7:16:31 | generic type instantiation expression | generic.go:16:7:16:28 | CircularGenericStruct1 | 0 | generic.go:16:30:16:30 | T | | generic.go:20:14:20:30 | generic type instantiation expression | generic.go:20:14:20:27 | GenericStruct1 | 0 | generic.go:20:29:20:29 | S | diff --git a/go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected b/go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected index 3d7e74b5a530e..847cb6603a0c4 100644 --- a/go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected +++ b/go/ql/test/library-tests/semmle/go/Types/QualifiedNames.expected @@ -1,4 +1,5 @@ | aliases.go:19:6:19:7 | S3 | codeql-go-types.S3 | +| aliases.go:29:6:29:9 | User | codeql-go-types.User | | cyclic.go:3:6:3:6 | s | codeql-go-types.s | | cyclic.go:7:6:7:6 | t | codeql-go-types.t | | cyclic.go:12:6:12:6 | u | codeql-go-types.u | diff --git a/go/ql/test/library-tests/semmle/go/Types/StructFields.expected b/go/ql/test/library-tests/semmle/go/Types/StructFields.expected index 1757e0cdaf95a..d644bb7d019ed 100644 --- a/go/ql/test/library-tests/semmle/go/Types/StructFields.expected +++ b/go/ql/test/library-tests/semmle/go/Types/StructFields.expected @@ -1,6 +1,7 @@ | aliases.go:19:6:19:7 | S3 | aliases.go:6:18:6:37 | struct type | x | int | | aliases.go:19:6:19:7 | S3 | aliases.go:8:18:8:37 | struct type | x | int | | aliases.go:19:6:19:7 | S3 | aliases.go:19:9:19:23 | struct type | x | int | +| aliases.go:29:6:29:9 | User | aliases.go:29:22:29:38 | struct type | x | UserT | | cyclic.go:3:6:3:6 | s | cyclic.go:3:8:5:1 | struct type | s | * s | | cyclic.go:7:6:7:6 | t | cyclic.go:7:8:10:1 | struct type | f | int | | cyclic.go:7:6:7:6 | t | cyclic.go:7:8:10:1 | struct type | t | t | diff --git a/go/ql/test/library-tests/semmle/go/Types/Types.expected b/go/ql/test/library-tests/semmle/go/Types/Types.expected index ab34dd4d8eef3..233891a2dedb1 100644 --- a/go/ql/test/library-tests/semmle/go/Types/Types.expected +++ b/go/ql/test/library-tests/semmle/go/Types/Types.expected @@ -1,4 +1,5 @@ | aliases.go:19:6:19:7 | S3 | S3 | +| aliases.go:29:6:29:9 | User | User | | cyclic.go:3:6:3:6 | s | s | | cyclic.go:7:6:7:6 | t | t | | cyclic.go:12:6:12:6 | u | u |