codeconsole opened a new pull request, #3045:
URL: https://github.com/apache/groovy/pull/3045

   When a class declares a static method or property with the same signature as 
its superclass, `super.sm()` threw `MissingMethodException` in dynamic Groovy 
and under `@TypeChecked`, or called another overload with `null`, and 
`super.sp` threw `MissingPropertyException`. Under `@CompileStatic`, 
`super.sm()` in a closure or lambda failed with `IncompatibleClassChangeError`. 
All of them now reach the superclass's static member, as in javac. Private 
static methods of the superclass stay out of reach. The same change fixes 
`super.first()` in a closure or lambda of an `ArrayList` subclass under 
`@CompileStatic`, which failed with `NoSuchMethodError`: an extension method is 
a static method too, so it needs no `super$` helper either.
   
   ```groovy
   class Base { static String sm() { 'base' } }
   class Sub extends Base {
       static String sm() { 'sub' }
       String test() { super.sm() }  // threw MissingMethodException; now 'base'
   }
   ```
   
   Split out of #3044.
   
   ## How
   
   The meta-class drops a method the class declares itself from the methods 
available to `super` calls, and nothing took the place of a static method that 
hides one of the superclass. A `super` call now finds the hidden static method 
of the nearest superclass that has one; the `super` property index is built 
from the same methods, so the static property accessors resolve too. Under 
`@CompileStatic`, a static target needs no `super$` helper in a closure: the 
call is an `invokestatic`, valid from any class.
   
   ## Behaviour change
   
   `super.sm()` and `super.sp` for a static member the class hides reach the 
superclass's member in dynamic Groovy and under `@TypeChecked`, where they 
failed or picked another overload before.
   
   ## Tests
   
   `groovy.ThisAndSuperTest`, in all three modes, including closures and 
lambdas, a static property read and written through `super`, a hidden method 
two levels up, the private case, and extension methods called through `super` 
from a closure and a lambda. They fail without the change. 14,938 tests in the 
`groovy`, `gls`, `bugs`, `org.codehaus.groovy.classgen`, `transform`, 
`runtime`, `reflection`, `vmplugin`, `control` and `ast` packages and the stub 
generator tests pass, apart from `bugs.Groovy12363`, which fails on master too 
when it runs after `bugs.Groovy12142` in the same JVM (#3025 fixes it). That 
run predates the last commit, which only adds the extension method test; 
`groovy.ThisAndSuperTest` passes with it. `groovy-contracts`, 
`groovy-typecheckers`, `groovy-ginq`, `groovy-macro-library`, `groovy-json`, 
`groovy-xml` and `groovy-templates` pass their tests, and every subproject 
compiles its main and test sources. The Checkstyle and CodeNarc gates pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to