зеркало из https://github.com/github/codeql-go.git
Fix type aliases for instantiated generic types
This commit is contained in:
Родитель
d098bdc7f8
Коммит
3c4b5202e3
|
@ -369,8 +369,10 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label)
|
|||
populateTypeParamParents(tw, funcObj.Type().(*types.Signature).TypeParams(), obj)
|
||||
populateTypeParamParents(tw, funcObj.Type().(*types.Signature).RecvTypeParams(), obj)
|
||||
}
|
||||
// Populate type parameter parents for named types.
|
||||
if typeNameObj, ok := obj.(*types.TypeName); ok {
|
||||
// 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() {
|
||||
if tp, ok := typeNameObj.Type().(*types.Named); ok {
|
||||
populateTypeParamParents(tw, tp.TypeParams(), obj)
|
||||
}
|
||||
|
|
|
@ -16,3 +16,4 @@
|
|||
| generic.go:62:12:62:26 | generic type instantiation expression | generic.go:62:12:62:23 | GenericNamed | 0 | generic.go:62:25:62:25 | U |
|
||||
| generic.go:70:42:70:64 | generic type instantiation expression | generic.go:70:42:70:57 | GenericInterface | 0 | generic.go:70:59:70:63 | int32 |
|
||||
| generic.go:74:41:74:62 | generic type instantiation expression | generic.go:74:41:74:54 | GenericStruct1 | 0 | generic.go:74:56:74:61 | string |
|
||||
| generic.go:82:18:82:34 | generic type instantiation expression | generic.go:82:18:82:29 | GenericArray | 0 | generic.go:82:31:82:33 | int |
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
| GenericMap2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericMap2 |
|
||||
| GenericNamed | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericNamed |
|
||||
| GenericPointer | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericPointer |
|
||||
| GenericSignature | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSignature |
|
||||
| GenericSlice | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericSlice |
|
||||
| GenericStruct1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericStruct1 |
|
||||
| GenericStruct2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Types.GenericStruct2 |
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
| GenericMap2 | GenericMap2 |
|
||||
| GenericNamed | GenericNamed |
|
||||
| GenericPointer | GenericPointer |
|
||||
| GenericSignature | GenericSignature |
|
||||
| GenericSlice | GenericSlice |
|
||||
| GenericStruct1 | GenericStruct1 |
|
||||
| GenericStruct2 | GenericStruct2 |
|
||||
|
|
|
@ -78,3 +78,8 @@ func accessFieldsOfInstantiatedStruct(x GenericStruct1[string]) {
|
|||
_ = x.sliceField
|
||||
_ = x.mapField
|
||||
}
|
||||
|
||||
type TypeAlias = GenericArray[int]
|
||||
|
||||
type GenericSignature[T any] func(t T) T
|
||||
type GenericSignatureAlias = GenericSignature[string]
|
||||
|
|
Загрузка…
Ссылка в новой задаче