Skip to content

Commit 048a530

Browse files
committed
Type parameter scoping check: distinguish type arguments from type parameters
I had forgotten that the Java QL lib regards a ParameterizedType as either an instantiation Generic<String>, or the unbound declaration Generic<T>.
1 parent b09b769 commit 048a530

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

java/ql/consistency-queries/typeParametersInScope.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import java
22

3+
class InstantiatedType extends ParameterizedType {
4+
InstantiatedType() {
5+
typeArgs(_, _, this)
6+
}
7+
}
8+
39
Type getAMentionedType(RefType type) {
410
result = type
511
or
612
result = getAMentionedType(type).(Array).getElementType()
713
or
8-
result = getAMentionedType(type).(ParameterizedType).getATypeArgument()
14+
result = getAMentionedType(type).(InstantiatedType).getATypeArgument()
915
or
1016
result = getAMentionedType(type).(NestedType).getEnclosingType()
1117
}
@@ -29,7 +35,7 @@ TypeVariable getATypeVariableInScope(RefType type) {
2935
or
3036
result = type.(GenericType).getATypeParameter()
3137
or
32-
result = getAMentionedType(type.(ParameterizedType).getATypeArgument())
38+
result = getAMentionedType(type.(InstantiatedType).getATypeArgument())
3339
or
3440
result = getATypeVariableInScope(type.getEnclosingType())
3541
}

0 commit comments

Comments
 (0)