Scott Murphy Heiberg created GROOVY-12526:
---------------------------------------------

             Summary: I.super.m() is not rejected when I is not a direct 
superinterface
                 Key: GROOVY-12526
                 URL: https://issues.apache.org/jira/browse/GROOVY-12526
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 6.0.0
            Reporter: Scott Murphy Heiberg


javac rejects {{I.super.m()}} unless {{I}} is a direct superinterface of the 
current class or interface ("not an enclosing class: I"). Groovy does not 
reject it, and dynamic Groovy runs something else:

{code:groovy}
interface J { default String m() { 'J' } }
interface I extends J {
    default String m() { 'I' }
    default String n() { I.super.m() }
}
class C implements I { }
assert new C().n() == 'I' // I's own m(), not J.m()
{code}

{code:groovy}
interface Outer {
    default String m() { 'outer' }
    class Inner {
        String test() { Outer.super.m() } // Inner does not implement Outer
    }
}
new Outer.Inner().test() // GroovyBugError: BUG! UNCAUGHT EXCEPTION: caller 
class must be a subclass below the method: Outer.m()String/invokeSpecial, from 
class Outer$Inner
{code}

Under {{@TypeChecked}} and {{@CompileStatic}} both are rejected, but with "No 
such property: super for Class or static property for class: I" (and "...: 
Outer"). Seen in 5.0.8, 6.0.0 and master. In 4.0.33 the first example returned 
'I' in every mode, and the second failed with {{MissingPropertyException}}.

Expected: a compile error in every mode, as javac gives.



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

Reply via email to