You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Juan Martín Sotuyo Dodero (JIRA)" <ji...@apache.org> on 2016/11/18 19:52:59 UTC

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

Juan Martín Sotuyo Dodero created GROOVY-8001:
-------------------------------------------------

             Summary: Static compiling fails type checking for 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


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
(v6.3.4#6332)