[ https://issues.apache.org/jira/browse/GROOVY-11305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17813989#comment-17813989 ]
Eric Milles commented on GROOVY-11305: -------------------------------------- inferLoopElemementType is static is the one complication > 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 > Priority: Minor > > Consider the following: > {code:groovy} > class C { // implicitly Iterable<String> > Iterator<String> iterator() {} // sometimes supplied via DGM > } > @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. > GROOVY-10476 describes the use case in more detail. -- This message was sent by Atlassian Jira (v8.20.10#820010)