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 2023/01/02 04:16:00 UTC

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

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

Eric Milles resolved GROOVY-10890.
----------------------------------
    Resolution: Fixed

https://github.com/apache/groovy/commit/4c7e608e2197b1530fabce59e12cc1bc3c0fb036

> 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
>            Assignee: Eric Milles
>            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)