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 2023/07/13 16:22:00 UTC
[jira] [Comment Edited] (GROOVY-11124) iterating Tuple2s loses type parameters
[ https://issues.apache.org/jira/browse/GROOVY-11124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17742861#comment-17742861 ]
Eric Milles edited comment on GROOVY-11124 at 7/13/23 4:21 PM:
---------------------------------------------------------------
This was caused by GROOVY-11089 and fixed by GROOVY-11090. In Groovy 4, the call inferLoopElementType(`Tuple2<String,String>`) is returning Object instead of String. This should get fixed.
If you do not use separate parameters to destructure the tuple, you should get the correct generics. Correct destructured tuple types is a Groovy 5 change (GROOVY-11090).
was (Author: emilles):
This was caused by GROOVY-11089 and fixed by GROOVY-11090. In Groovy 4, the call "inferLoopElementType(`Tuple2<String,String>`)" is returning Object instead of String. This should get fixed.
If you do not use separate parameters to destructure the tuple, you should get the correct generics. Correct destructured tuple types is a Groovy 5 change (GROOVY-11090).
> iterating Tuple2s loses type parameters
> ---------------------------------------
>
> Key: GROOVY-11124
> URL: https://issues.apache.org/jira/browse/GROOVY-11124
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.13
> Reporter: Jason Garrett
> Assignee: Eric Milles
> Priority: Minor
>
> With static compilation, when iterating a collection of Tuple2s, the Tuple2's type parameters are lost.
> This example fails to compile:
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic // compiles successfully without this
> class Tuple2Parameters {
> List<Tuple2<String, String>> myList = []
> void myMethod() {
> myList.each { String first, String second -> // [Static type checking] - Expected type java.lang.Object for closure parameters
> true
> }
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)