Type-variable-in-scope consistency query: account for all enclosing elements that declare type parameters.

This commit is contained in:
Chris Smowton
2022-05-11 19:15:45 +01:00
parent 4e15f5f8c7
commit 49c9c36daf

View File

@@ -30,14 +30,22 @@ Type getATypeUsedInClass(RefType type) {
result = getAMentionedType(getATypeUsedInClass(type))
}
Element getEnclosingElementStar(RefType e) {
result = e
or
result.contains(e)
}
TypeVariable getATypeVariableInScope(RefType type) {
result = type.getACallable().(GenericCallable).getATypeParameter()
or
result = type.(GenericType).getATypeParameter()
or
result = getAMentionedType(type.(InstantiatedType).getATypeArgument())
or
result = getATypeVariableInScope(type.getEnclosingType())
exists(Element e | e = getEnclosingElementStar(type) |
result = e.(RefType).getACallable().(GenericCallable).getATypeParameter()
or
result = e.(GenericType).getATypeParameter()
or
result = e.(GenericCallable).getATypeParameter()
or
result = getAMentionedType(e.(InstantiatedType).getATypeArgument())
)
}
from ClassOrInterface typeUser, TypeVariable outOfScope