[ 
https://issues.apache.org/jira/browse/GROOVY-11305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles resolved GROOVY-11305.
----------------------------------
    Fix Version/s: 5.0.0-alpha-11
       Resolution: Fixed

https://github.com/apache/groovy/commit/cef611c2d22e76be5a8b3e1cc73d3774a3a997e9

> 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
>             Fix For: 5.0.0-alpha-11
>
>
> 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)

Reply via email to