[
https://issues.apache.org/jira/browse/GROOVY-12592?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Scott Murphy Heiberg updated GROOVY-12592:
------------------------------------------
Description:
{code:groovy}
class Base { String m() { 'base' } }
class Root extends Base { String m() { 'root' } }
class Outer extends Root {
class Inner { String test() { Outer.super.m() } }
String viaClosure() { def c = { -> super.m() }; c() }
}
def o = new Outer()
assert new Outer.Inner(o).test() == 'root'
assert o.viaClosure() == 'root'
{code}
Actual: both calls return 'base'.
Expected: both return 'root', the method Outer inherits from Root, as a super
call in a method of Outer does.
A super call from a nested class or a closure does not create a super$ MOP
method in Outer. MetaClassImpl then takes the super$ MOP method of Root, which
calls Root's super method, Base.m, so Root's override is skipped. The closure
form is the same in 4.0.33; Outer.super is not supported there.
PR: https://github.com/apache/groovy/pull/3118
was:
{code:groovy}
class Base { String m() { 'base' } }
class Root extends Base { String m() { 'root' } }
class Outer extends Root {
class Inner { String test() { Outer.super.m() } }
String viaClosure() { def c = { -> super.m() }; c() }
}
def o = new Outer()
assert new Outer.Inner(o).test() == 'root'
assert o.viaClosure() == 'root'
{code}
Actual: both calls return 'base'.
Expected: both return 'root', the method Outer inherits from Root, as a super
call in a method of Outer does.
A super call from a nested class or a closure does not create a super$ MOP
method in Outer. MetaClassImpl then takes the super$ MOP method of Root, which
calls Root's super method, Base.m, so Root's override is skipped. The closure
form is the same in 4.0.33; Outer.super is not supported there.
> Outer.super.name() and super.name() in a closure skip the method the class
> inherits
> -----------------------------------------------------------------------------------
>
> Key: GROOVY-12592
> URL: https://issues.apache.org/jira/browse/GROOVY-12592
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.33, 5.0.8, 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> class Base { String m() { 'base' } }
> class Root extends Base { String m() { 'root' } }
> class Outer extends Root {
> class Inner { String test() { Outer.super.m() } }
> String viaClosure() { def c = { -> super.m() }; c() }
> }
> def o = new Outer()
> assert new Outer.Inner(o).test() == 'root'
> assert o.viaClosure() == 'root'
> {code}
> Actual: both calls return 'base'.
> Expected: both return 'root', the method Outer inherits from Root, as a super
> call in a method of Outer does.
> A super call from a nested class or a closure does not create a super$ MOP
> method in Outer. MetaClassImpl then takes the super$ MOP method of Root,
> which calls Root's super method, Base.m, so Root's override is skipped. The
> closure form is the same in 4.0.33; Outer.super is not supported there.
> PR: https://github.com/apache/groovy/pull/3118
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)