[jira] [Comment Edited] (GROOVY-11265) Runtime rehydrate error for closure in interface default method
[ https://issues.apache.org/jira/browse/GROOVY-11265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17803666#comment-17803666 ] Eric Milles edited comment on GROOVY-11265 at 1/5/24 6:41 PM: -- {code:groovy} def closure = { -> ... } def lambda = () -> { ... } {code} They are close but not the same. The first creates a {{ClosureExpression}} and the second a {{{}LambdaExpression{}}}. LE extends CE so they share a lot of behavior and only really differ under static compilation in the presence of a {{{}@FunctionalInterface{}}}. was (Author: emilles): {code:groovy} def closure = { -> ... } def lambda = () -> { ... } {code} They are close but not the same. The first creates a {{ClosureExpression}} and the second a {{{}LambdaExpression{}}}. LE extends CE so they share a lot of behavior and only really differ under static compilation in the presence of {{{}@FunctionalInterface{}}}. > Runtime rehydrate error for closure in interface default method > --- > > Key: GROOVY-11265 > URL: https://issues.apache.org/jira/browse/GROOVY-11265 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 4.0.13, 4.0.17 >Reporter: Christopher Smith >Assignee: Eric Milles >Priority: Critical > Labels: traits > > 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 > {code} > groovy.lang.MissingMethodException: No signature of method: > com.example.MyInterface$Trait$Helper$$Lambda$2132/0x000800e24c40.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) > {code} > 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-11265) Runtime rehydrate error for closure in interface default method
[ https://issues.apache.org/jira/browse/GROOVY-11265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17803666#comment-17803666 ] Eric Milles edited comment on GROOVY-11265 at 1/5/24 6:40 PM: -- {code:groovy} def closure = { -> ... } def lambda = () -> { ... } {code} They are close but not the same. The first creates a {{ClosureExpression}} and the second a {{{}LambdaExpression{}}}. LE extends CE so they share a lot of behavior and only really differ under static compilation in the presence of {{{}@FunctionalInterface{}}}. was (Author: emilles): {code:groovy} def closure = { -> ... } def lambda = () -> { ... } {code} They are close but not the same. The first creates a {{ClosureExpression}} and the second a {{LambdaExpression}}. LE exteds CE so they share a lot of behavior and only really differ under static compilation in the presence of {{@FunctionalInterface}}. > Runtime rehydrate error for closure in interface default method > --- > > Key: GROOVY-11265 > URL: https://issues.apache.org/jira/browse/GROOVY-11265 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 4.0.13, 4.0.17 >Reporter: Christopher Smith >Assignee: Eric Milles >Priority: Critical > Labels: traits > > 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 > {code} > groovy.lang.MissingMethodException: No signature of method: > com.example.MyInterface$Trait$Helper$$Lambda$2132/0x000800e24c40.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) > {code} > 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-11265) Runtime rehydrate error for closure in interface default method
[ https://issues.apache.org/jira/browse/GROOVY-11265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17803615#comment-17803615 ] Eric Milles edited comment on GROOVY-11265 at 1/5/24 4:40 PM: -- Sorry, if you use lambda syntax it goes to the lambda factory. So, in your original example, you should be able to keep static compilation and use a closure for the return as a workaround. was (Author: emilles): Sorry, if you use lambda syntax it goes to the lambda factory. > Runtime rehydrate error for closure in interface default method > --- > > Key: GROOVY-11265 > URL: https://issues.apache.org/jira/browse/GROOVY-11265 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 4.0.13, 4.0.17 >Reporter: Christopher Smith >Assignee: Eric Milles >Priority: Critical > > 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 > {code} > groovy.lang.MissingMethodException: No signature of method: > com.example.MyInterface$Trait$Helper$$Lambda$2132/0x000800e24c40.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) > {code} > 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-11265) Runtime rehydrate error for closure in interface default method
[ https://issues.apache.org/jira/browse/GROOVY-11265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17803595#comment-17803595 ] Eric Milles edited comment on GROOVY-11265 at 1/5/24 4:08 PM: -- Regarding {{clientProfile.roleIdentities.forEach \{ id, orgs -> clientDto.doSomethingWithOrgs(orgs) };}} you should get a closure for dynamic compilation that is proxy-adapted to {{{}BiConsumer{}}}. For static compilation, you should get a lambda-factory implementation of {{{}BiConsumer{}}}. was (Author: emilles): Regarding {{clientProfile.roleIdentities.forEach \{ id, orgs -> clientDto.doSomethingWithOrgs(orgs) \};}} you should get a closure for dynamic compilation that is proxy adapted to {{BiConsumer}}. For static compilation, you should get a lambda-factory implementation of {{BiConsumer}}. > Runtime rehydrate error for closure in interface default method > --- > > Key: GROOVY-11265 > URL: https://issues.apache.org/jira/browse/GROOVY-11265 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 4.0.13, 4.0.17 >Reporter: Christopher Smith >Assignee: Eric Milles >Priority: Critical > > 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 > {code} > groovy.lang.MissingMethodException: No signature of method: > com.example.MyInterface$Trait$Helper$$Lambda$2132/0x000800e24c40.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) > {code} > 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-11265) Runtime rehydrate error for closure in interface default method
[ https://issues.apache.org/jira/browse/GROOVY-11265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17803595#comment-17803595 ] Eric Milles edited comment on GROOVY-11265 at 1/5/24 4:07 PM: -- Regarding {{clientProfile.roleIdentities.forEach \{ id, orgs -> clientDto.doSomethingWithOrgs(orgs) \};}} you should get a closure for dynamic compilation that is proxy adapted to {{BiConsumer}}. For static compilation, you should get a lambda-factory implementation of {{BiConsumer}}. was (Author: emilles): Regarding {{clientProfile.roleIdentities.forEach \{ id, orgs -> clientDto.doSomethingWithOrgs(orgs) \} }} you should get a closure for dynamic compilation that is proxy adapted to {{BiConsumer}}. For static compilation, you should get a lambda-factory implementation of {{BiConsumer}}. > Runtime rehydrate error for closure in interface default method > --- > > Key: GROOVY-11265 > URL: https://issues.apache.org/jira/browse/GROOVY-11265 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 4.0.13, 4.0.17 >Reporter: Christopher Smith >Assignee: Eric Milles >Priority: Critical > > 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 > {code} > groovy.lang.MissingMethodException: No signature of method: > com.example.MyInterface$Trait$Helper$$Lambda$2132/0x000800e24c40.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) > {code} > 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. -- This message was sent by Atlassian Jira (v8.20.10#820010)