mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Java: Get the correct type of the instantiated iterator type.
This commit is contained in:
@@ -12,17 +12,17 @@ private class IterableType extends Class {
|
||||
private Type elementType;
|
||||
|
||||
IterableType() {
|
||||
exists(Method m, Type return, Type t | m.getDeclaringType() = t |
|
||||
exists(Method m, Type return, GenericType t, Type et, int position | m.getDeclaringType() = t |
|
||||
return = m.getReturnType() and
|
||||
return.getName().matches("Iterator%") and
|
||||
elementType = return.(ParameterizedType).getTypeArgument(0) and
|
||||
(this = t or instantiates(this, t, _, _))
|
||||
et = return.(ParameterizedType).getTypeArgument(0) and
|
||||
t.getTypeParameter(position) = et and
|
||||
instantiates(this, t, position, elementType)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the iterator element type of `this`.
|
||||
* TODO: Improve this as it doesn't return the correct type instantiations.
|
||||
*/
|
||||
Type getElementType() { result = elementType }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user