You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/07/30 14:42:00 UTC

[jira] [Resolved] (GROOVY-10712) STC: for-each over Iterator fails to infer element type

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

Eric Milles resolved GROOVY-10712.
----------------------------------
    Fix Version/s: 4.0.5
       Resolution: Fixed

https://github.com/apache/groovy/commit/8cc66b5f992f1a6bc18654de3ea8f1ec741f9cf2

> STC: for-each over Iterator fails to infer element type
> -------------------------------------------------------
>
>                 Key: GROOVY-10712
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10712
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 4.0.4
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.5
>
>
> Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test() {
>   def list = ['a','b']
>   for (item in list.iterator()) {
>     item.toUpperCase() // Cannot find matching method Object#toUpperCase()
>   }
> }
> {code}
> Inferred type of "item" is {{java.lang.Object}}.  Without ".iterator()" it is {{java.lang.String}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)