You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Christopher Smith (Jira)" <ji...@apache.org> on 2022/12/30 22:28:00 UTC

[jira] [Updated] (GROOVY-10890) Generics regression in method call

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

Christopher Smith updated GROOVY-10890:
---------------------------------------
    Description: 
I'm receiving a compile-time error on an invocation that is semantically correct and worked in 4.0.6. When using the {{EnumMap}} copy constructor, the STC appears to misinfer the type as {{<V, V>}} instead of {{<K, V>}}. The problem seems to present itself only when {{V}} is also an enum type (of course, {{K}} must be an enum type).

{code}
@CompileStatic
class Example {

    enum Foo {}
    enum Bar {}

    void run(Map<Foo, Bar> input) {
        error(new EnumMap<>(input))  // error here
    }

    void error(Map<Foo, Bar> input) {
    }
}
{code}

{code}
Groovy:[Static type checking] - Cannot call Example#error(java.util.Map<Example.Foo, Example.Bar>) with arguments [java.util.EnumMap<Example.Bar, Example.Bar>]	{code}

  was:
I'm receiving a compile-time error on an invocation that is semantically correct and worked in 4.0.6. When using the {{EnumMap}} copy constructor, the STC appears to misinfer the type as {{<V, V>}} instead of {{<K, V>}}. The problem seems to present itself only when {{V}} is also an enum type (of course, {{K}} must be an enum type).

{code}
@CompileStatic
class Example {

    enum Foo {}
    enum Bar {}

    void run(Map<Foo, Bar> input) {
        error(new EnumMap<>(input))  // error here
    }

    void error(Map<Foo, Bar> input) {
    }
}
{code}

{code}
Groovy:[Static type checking] - Cannot call .Example#error(java.util.Map<Example.Foo, Example.Bar>) with arguments [java.util.EnumMap<Example.Bar, Example.Bar>]	{code}


> Generics regression in method call
> ----------------------------------
>
>                 Key: GROOVY-10890
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10890
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 4.0.7
>            Reporter: Christopher Smith
>            Priority: Major
>              Labels: generics, regression
>
> I'm receiving a compile-time error on an invocation that is semantically correct and worked in 4.0.6. When using the {{EnumMap}} copy constructor, the STC appears to misinfer the type as {{<V, V>}} instead of {{<K, V>}}. The problem seems to present itself only when {{V}} is also an enum type (of course, {{K}} must be an enum type).
> {code}
> @CompileStatic
> class Example {
>     enum Foo {}
>     enum Bar {}
>     void run(Map<Foo, Bar> input) {
>         error(new EnumMap<>(input))  // error here
>     }
>     void error(Map<Foo, Bar> input) {
>     }
> }
> {code}
> {code}
> Groovy:[Static type checking] - Cannot call Example#error(java.util.Map<Example.Foo, Example.Bar>) with arguments [java.util.EnumMap<Example.Bar, Example.Bar>]	{code}



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