Scott Murphy Heiberg created GROOVY-12618:
---------------------------------------------

             Summary: A public static super trait method called from a closure 
in trait code ignores the closure's delegate
                 Key: GROOVY-12618
                 URL: https://issues.apache.org/jira/browse/GROOVY-12618
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 5.0.8, 6.0.0
            Reporter: Scott Murphy Heiberg


{code:groovy}
trait T { static int size() { 1 } }
trait U extends T {
    def m() { [5, 6].with { size() } }
    static sm() { [5, 6].with { size() } }
}
class C implements U {}
assert new C().m() == 2
assert C.sm() == 2
{code}
Actual: both calls return 1, in dynamic, @TypeChecked and @CompileStatic code.

Expected: 2, as with the same code written with classes. Inside a with closure, 
the list delegate's size() comes before the owner's.

The trait transformation rewrites an implicit-this call to a public static 
method inherited from a super trait into a direct call on the trait helper 
class, so the closure's delegate is never consulted. GROOVY-12611 changes this 
for private and static methods declared by the trait itself, but not for 
methods inherited from a super trait.

Seen in 5.0.8 and 6.0.0.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to