[ 
https://issues.apache.org/jira/browse/GROOVY-10588?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17897277#comment-17897277
 ] 

Eric Milles commented on GROOVY-10588:
--------------------------------------

I believe this should be a compile-time error.  It is not known what value 
types are in {{formData}} and {{csrfTokenField}}.  So the compiler cannot 
safely assume that they can be combined.

GROOVY-8084 and GROOVY-9074 touch on this.  There should be a more complete 
description here: 
https://docs.oracle.com/javase/tutorial/extra/generics/wildcards.html

> TypeChecked/CompileStatic wildcard problems
> -------------------------------------------
>
>                 Key: GROOVY-10588
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10588
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.1
>            Reporter: Leonard Brünings
>            Assignee: Eric Milles
>            Priority: Major
>
> The following works fine in 2.x/3x but fails with Groovy 4.0.1
> {code:groovy}
> @groovy.transform.CompileStatic
> class Reproducer {
>     
>     Map<String, ?> formData = [:]
>     
>     Map<String, ?> getCsrfTokenField() {
>         [:]
>     }
>     
>     def broken() {
>               resolveFormData(formData + csrfTokenField)
>     }
>     
>     static Map<String, String> resolveFormData(Map<String, ?> formData) {
>         formData.collectEntries { k, v -> [k, v instanceof Closure ? 
> v().toString() : v] }
>     }
>     
>     static void main(String... args) {
>       println 'compiled successfully'   
>     }
> }
> {code}
> Fails with
> {noformat}
> [Static type checking] - Cannot call <K,V> 
> org.codehaus.groovy.runtime.DefaultGroovyMethods#plus(java.util.Map<K, V>, 
> java.util.Map<K, V>) with arguments [java.util.Map<java.lang.String, ?>, 
> java.util.Map<java.lang.String, ? extends java.lang.Object>]
>  @ line 11, column 19.
> {noformat}
> [Groovy Web 
> Console|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJx1UctqwzAQPNtfsbfYNNUHhNYJuM2tl6a3kIMqr42IrDVa2RCC_71-t0nJHCSxzM4D7QpH1FyEd9JyTq4UKZWVNnjw0msVKiOZ4RMrR1mt0ME1hA7D8SGrl4N32hZr2CbQb79JL-EVjpvTQ1qBPmWXf9EZ7V6jyaJ4Eu0xb7a_-xnm8O16-sAMAodMpsH95Bctxk-gbpTjeykeSt0kGu8E7kUflPubdZ4JRcag8u-24yPDFc5raOA5gePw0LbztQoph9QQ1w5hC00UC0-jQ9drA81pSvo_b0M6g1JqG418IQRIV_ASJqi6sTcWVmr8vQy4VgqZ89qYy2rWa8M2DJf8PX4A4IWY-g]



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

Reply via email to