You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Leonard Brünings (Jira)" <ji...@apache.org> on 2022/04/28 14:10:00 UTC
[jira] [Created] (GROOVY-10605) Regression of method argument resolution with Groovy 4
Leonard Brünings created GROOVY-10605:
-----------------------------------------
Summary: Regression of method argument resolution with Groovy 4
Key: GROOVY-10605
URL: https://issues.apache.org/jira/browse/GROOVY-10605
Project: Groovy
Issue Type: Bug
Affects Versions: 4.0.2
Reporter: Leonard Brünings
{code:groovy}
class Reproducer {
public static final Map<Role, String> ROLE_MAPPING = EnumMap.of(Role.A, 'a')
// public static final Map<Role, String> ROLE_MAPPING = EnumMap.of(Role.A, 'a', Role.B, 'b', Role.C, 'c', Role.D, 'd')
static void main(String... args) {
println ROLE_MAPPING
}
}
enum Role {
A, B, C, D
}
{code}
([Groovy Web Console|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJytj0EKgzAQRfc5xexUkHiBtmBbKYXaij1AiRolEKMksZvi3TumEdp9Z5Hh8Wfm_9SSGQMlH_XQTDXX8CKANU6VFDUYyyy2VigmIWfjphwkj-FutVDdDsrbJXvkaVGcryfYQqamHofo0IbLHE1jCFgQuYNJAn--G4ODPUK1wgGhXuGI0Hh793jX5yAa6JlQ4cePUgpMdybyf3c5UbBS_SRx4kxmQjgGch5-AwNhDDQ_Lip81Rs8JmML])
Works fine in Groovy 2.5 and 3.x but fails with Groovy 4.
{noformat}
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.MissingMethodException: No signature of method: static java.util.EnumMap.of() is applicable for argument types: (Role, String) values: [A, a]
Possible solutions: any(), sort(), is(java.lang.Object), notify(), wait(), size()
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1677)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1663)
at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
at Reproducer.<clinit>(Script1.groovy:2)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)