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 2021/04/02 14:39:00 UTC

[jira] [Resolved] (GROOVY-8001) Static compiling fails type checking with generics

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

Eric Milles resolved GROOVY-8001.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> Static compiling fails type checking with generics
> --------------------------------------------------
>
>                 Key: GROOVY-8001
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8001
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.7
>            Reporter: Juan Martín Sotuyo Dodero
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>
> Given a property of type {{Map<String, Object>}} and the assignment:
> {code}
> myObject.property = ['myKey':"${buildDir}/file-cache"]
> {code}
> I get the following error:
> {quote}
> [Static type checking] - Cannot assign value of type java.util.LinkedHashMap <java.lang.String, groovy.lang.GString> to variable of type java.util.Map <java.lang.String, java.lang.Object>
> {quote}
> I have to manually cast the value to {{Object}} for it to work without warnings:
> {code}
> myObject.property = ['myKey': "${buildDir}/file-cache" as Object]
> {code}
> This should not be needed, since any object is a valid instance of {{Object}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)