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

Runtime rehydrate error for closure in interface default method

    XMLWordPrintableJSON

Details

    Description

      When using an interface default method (implemented in Groovy 4 as a trait) that returns an instance of a functional interface defined by a lambda, compilation succeeds but runtime invocation produces

      groovy.lang.MissingMethodException: No signature of method: com.example.MyInterface$Trait$Helper$$Lambda$2132/0x0000000800e24c40.rehydrate() is applicable for argument types: (com.example.MyImplementation...) values: [com.example.MyImplementation@2a7087a8, ...]
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:184)
              at com.example.MyInterface$Trait$Helper.curry(MyInterface.groovy:19)
              at com.example.MyImplementation.curry(MyImplementation.groovy)
      

      Update: This appears to be a problem introduced between 4.0.12 and 4.0.13 and shows up only when the interface is defined as @CompileStatic. While I understand that the party line is that traits and ASTTs aren't guaranteed to be compatible, (1) this was working perfectly previously and (2) the compiler's implementation of interface default methods as traits is an implementation detail and should have as limited a blast radius as practical.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              chrylis Christopher Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: