[ 
https://issues.apache.org/jira/browse/GROOVY-12517?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Scott Murphy Heiberg updated GROOVY-12517:
------------------------------------------
    Description: 
In an inner class of {{Outer}}, {{Outer.super.m()}} calls the superclass's 
method {{m()}} on the enclosing {{Outer}} instance (JLS 15.12.1). The type 
checker rejects it:

{code:groovy}
class Base {
    String m() { 'base' }
}
@groovy.transform.CompileStatic
class Outer extends Base {
    String m() { 'outer' }
    class Inner {
        String test() { Outer.super.m() }
    }
}
new Outer.Inner(new Outer()).test()
{code}

{code}
[Static type checking] - No such property: super for Class or static property 
for class: Outer
{code}

The same error is reported under {{@TypeChecked}}, and for a property, 
{{Outer.super.p}} with a {{getP()}} in both classes. Dynamic Groovy returns 
{{base}} for the method call, but {{p:outer}} for the property, which it reads 
as {{Outer.this.p}}. javac accepts both and prints {{base}} and {{p:base}} (for 
the property through {{Outer.super.getP()}}). Seen in 5.0.8, 6.0.0 and master; 
in 4.0.33 dynamic Groovy also failed, with {{MissingPropertyException: No such 
property: super for class: Outer}}.

Expected: {{Outer.super.m()}} and {{Outer.super.p}} in an inner class (also in 
an anonymous class, in a closure or lambda, or in an inner class of an inner 
class) call the superclass's member on the enclosing {{Outer}} instance, in 
every mode. Where the class has no enclosing instance of {{Outer}} (a static 
nested class, or an anonymous class created in a static context), it stays an 
error.

PR: https://github.com/apache/groovy/pull/3049

  was:
In an inner class of {{Outer}}, {{Outer.super.m()}} calls the superclass's 
method {{m()}} on the enclosing {{Outer}} instance (JLS 15.12.1). The type 
checker rejects it:

{code:groovy}
class Base {
    String m() { 'base' }
}
@groovy.transform.CompileStatic
class Outer extends Base {
    String m() { 'outer' }
    class Inner {
        String test() { Outer.super.m() }
    }
}
new Outer.Inner(new Outer()).test()
{code}

{code}
[Static type checking] - No such property: super for Class or static property 
for class: Outer
{code}

The same error is reported under {{@TypeChecked}}, and for a property, 
{{Outer.super.p}} with a {{getP()}} in both classes. Dynamic Groovy returns 
{{base}} for the method call, but {{p:outer}} for the property, which it reads 
as {{Outer.this.p}}. javac accepts both and prints {{base}} and {{p:base}} (for 
the property through {{Outer.super.getP()}}). Seen in 5.0.8, 6.0.0 and master; 
in 4.0.33 dynamic Groovy also failed, with {{MissingPropertyException: No such 
property: super for class: Outer}}.

Expected: {{Outer.super.m()}} and {{Outer.super.p}} in an inner class (also in 
an anonymous class, in a closure or lambda, or in an inner class of an inner 
class) call the superclass's member on the enclosing {{Outer}} instance, in 
every mode. Where the class has no enclosing instance of {{Outer}} (a static 
nested class, or an anonymous class created in a static context), it stays an 
error.

PR: https://github.com/apache/groovy/pull/3049 (split out of 
https://github.com/apache/groovy/pull/3044)


> Qualified super naming an enclosing class (Outer.super.m() in an inner class) 
> is rejected by static type checking
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12517
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12517
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> In an inner class of {{Outer}}, {{Outer.super.m()}} calls the superclass's 
> method {{m()}} on the enclosing {{Outer}} instance (JLS 15.12.1). The type 
> checker rejects it:
> {code:groovy}
> class Base {
>     String m() { 'base' }
> }
> @groovy.transform.CompileStatic
> class Outer extends Base {
>     String m() { 'outer' }
>     class Inner {
>         String test() { Outer.super.m() }
>     }
> }
> new Outer.Inner(new Outer()).test()
> {code}
> {code}
> [Static type checking] - No such property: super for Class or static property 
> for class: Outer
> {code}
> The same error is reported under {{@TypeChecked}}, and for a property, 
> {{Outer.super.p}} with a {{getP()}} in both classes. Dynamic Groovy returns 
> {{base}} for the method call, but {{p:outer}} for the property, which it 
> reads as {{Outer.this.p}}. javac accepts both and prints {{base}} and 
> {{p:base}} (for the property through {{Outer.super.getP()}}). Seen in 5.0.8, 
> 6.0.0 and master; in 4.0.33 dynamic Groovy also failed, with 
> {{MissingPropertyException: No such property: super for class: Outer}}.
> Expected: {{Outer.super.m()}} and {{Outer.super.p}} in an inner class (also 
> in an anonymous class, in a closure or lambda, or in an inner class of an 
> inner class) call the superclass's member on the enclosing {{Outer}} 
> instance, in every mode. Where the class has no enclosing instance of 
> {{Outer}} (a static nested class, or an anonymous class created in a static 
> context), it stays an error.
> PR: https://github.com/apache/groovy/pull/3049



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

Reply via email to