You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Josh DeWitt (Jira)" <ji...@apache.org> on 2022/08/02 21:20:00 UTC
[jira] [Commented] (GROOVY-8243) SAM trait coercion via middle interface
[ https://issues.apache.org/jira/browse/GROOVY-8243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17574402#comment-17574402 ]
Josh DeWitt commented on GROOVY-8243:
-------------------------------------
Not sure if this is the appropriate ticket, but as of 3.0.11 the below code no longer works; it now prints out {{null}} instead of {{{}string b{}}}. Seems like it is relying on the native object instead of the {{{}$closure$delegate$map{}}}?
{code:java}
abstract class A {
String b
}
def a = [getB: { 'string b' }] as A
println a.b
{code}
> SAM trait coercion via middle interface
> ---------------------------------------
>
> Key: GROOVY-8243
> URL: https://issues.apache.org/jira/browse/GROOVY-8243
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.10
> Reporter: Daniil Ovchinnikov
> Assignee: Eric Milles
> Priority: Major
> Labels: trait, traits
> Fix For: 3.0.11, 4.0.2
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> {code}
> trait T {
> abstract def foo(int i)
> def bar(double j) {
> println "bar $j"
> }
> }
> interface F extends T {}
> F t = { println "closure $it" }
> t.foo(42) // `closure 42`
> t.bar(43) // `closure 43.0`; should be `bar 43.0`
> {code}
> Changing variable type to {{T}} works as expected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)