Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39ee1e2

Browse files
committed
Java: Get the correct type of the instantiated iterator type.
1 parent dc79ed8 commit 39ee1e2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

java/ql/src/utils/model-generator/internal/CaptureTypeBasedSummaryModels.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ private class IterableType extends Class {
1212
private Type elementType;
1313

1414
IterableType() {
15-
exists(Method m, Type return, Type t | m.getDeclaringType() = t |
15+
exists(Method m, Type return, GenericType t, Type et, int position | m.getDeclaringType() = t |
1616
return = m.getReturnType() and
1717
return.getName().matches("Iterator%") and
18-
elementType = return.(ParameterizedType).getTypeArgument(0) and
19-
(this = t or instantiates(this, t, _, _))
18+
et = return.(ParameterizedType).getTypeArgument(0) and
19+
t.getTypeParameter(position) = et and
20+
instantiates(this, t, position, elementType)
2021
)
2122
}
2223

2324
/**
2425
* Returns the iterator element type of `this`.
25-
* TODO: Improve this as it doesn't return the correct type instantiations.
2626
*/
2727
Type getElementType() { result = elementType }
2828
}

0 commit comments

Comments
 (0)