Eric Milles created GROOVY-11305:
------------------------------------
Summary: STC: support for-each or for-in loop for
implicitly-Iterable type
Key: GROOVY-11305
URL: https://issues.apache.org/jira/browse/GROOVY-11305
Project: Groovy
Issue Type: Improvement
Components: Static Type Checker
Reporter: Eric Milles
Assignee: Eric Milles
Consider the following:
{code:groovy}
class C { // implicitly Iterable<String>
Iterator<String> iterator() {}
}
@TypeChecked
void test(C c) {
for (string in c) {
string.toUpperCase()
}
}
{code}
If "@TypeChecked" is removed, this works. STC cannot determine the loop
element type -- see {{StaticTypeCheckingVisitor#inferLoopElementType}} and
compare with {{inferComponentType}} which runs for spread.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)