groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kenzie Togami (JIRA)" <>
Subject [jira] [Created] (GROOVY-8828) Union types incorrectly resolved
Date Sat, 06 Oct 2018 08:55:00 GMT
Kenzie Togami created GROOVY-8828:

             Summary: Union types incorrectly resolved
                 Key: GROOVY-8828
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 2.5.3, 2.4.13
            Reporter: Kenzie Togami

UsingĀ {{@CompileStatic}} breaks {{Map#put}} if the operand is a UnionType due to this change
(found by using {{git bisect}}):

Error: {code}src/main/groovy/pkg/Main.groovy: 12: [Static type checking] - Cannot call java.util.LinkedHashMap
<java.lang.String, pkg.Foo>#put(java.lang.String, pkg.Foo) with arguments [java.lang.String,

Sample code:
Line 12 in Main.groovy will fail to compile.

There is a workaround for this, which is to explicitly cast the variable to the Map's type.
Changing line 12 to {{map.put(name, (Foo) foo)}} will allow the code to compile. However,
this is clearly not the expected behavior.

This message was sent by Atlassian JIRA

View raw message