You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2024/11/12 11:39:00 UTC
[jira] [Closed] (GROOVY-11305) STC: support for-each or for-in loop for implicitly-Iterable type
[ https://issues.apache.org/jira/browse/GROOVY-11305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-11305.
------------------------------
> 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)