Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10605

Regression of method argument resolution with Groovy 4

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 4.0.2
    • None
    • None
    • None

    Description

      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
      }
      

      (Groovy Web Console)

      Works fine in Groovy 2.5 and 3.x but fails with Groovy 4.

      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)
             ...
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              leonard84 Leonard Brünings
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: