mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Previously because extractClassInstance didn't use the declaration stack, we wouldn't notice that it was legal to refer to its type variable in the context of extracting a specialised method <-> method source-decl edge. This led to erasing the types of the source-decl, so that e.g. Map.put(...) would have signature (Object, Object) not (K, V) as it should.
20 lines
622 B
Plaintext
20 lines
622 B
Plaintext
import java
|
|
|
|
class InstantiatedType extends ParameterizedType {
|
|
InstantiatedType() { typeArgs(_, _, this) }
|
|
}
|
|
|
|
// This checks that all type parameter references are erased in the context of a $default function.
|
|
predicate containsTypeVariables(Type t) {
|
|
t instanceof TypeVariable or
|
|
containsTypeVariables(t.(InstantiatedType).getATypeArgument()) or
|
|
containsTypeVariables(t.(NestedType).getEnclosingType()) or
|
|
containsTypeVariables(t.(Wildcard).getATypeBound().getType())
|
|
}
|
|
|
|
from Expr e
|
|
where
|
|
e.getEnclosingCallable().getName().matches("%$default") and
|
|
containsTypeVariables(e.getType())
|
|
select e, e.getType()
|