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

   When a class declares its own version of an extension method of its 
superclass, such as `first()` in an `ArrayList` subclass, `getProperties()`, or 
`getText()` in a `File` subclass, `super.first()`, `super.properties` and 
`super.getText()` in dynamic Groovy and under `@TypeChecked` threw 
`MissingMethodException` or `MissingPropertyException`, or called 
`getText(File, String)` with a null charset. Under `@CompileStatic`, 
`super.text += v` compiles to a dynamic property access and failed the same 
way. They now call the superclass's extension method, as they do when the class 
does not declare one. This happens in 4.0.33 to master.
   
   ```groovy
   class Numbers extends ArrayList<Integer> {
       Numbers() { super([1, 2, 3]) }
       Integer first() { -1 }
       def test() { super.first() }  // threw MissingMethodException; now 1
   }
   ```
   
   Split out of #3044.
   
   ## How
   
   For `super` usage, the meta-class replaces a method the class declares with 
the MOP method `super$N$name` of the superclass method it overrides, and drops 
it when there is none. An extension method has no MOP method, so the class's 
method was dropped, and the extension method it had replaced in the method 
index was not restored. It now is: the extension method of the superclass, or 
of an interface it implements, with the same parameters, the one for the most 
specific type. The lookup is built once per class, by name.
   
   ## Tests
   
   `groovy.ThisAndSuperTest`, in all three modes, and in a closure in dynamic 
Groovy and under `@TypeChecked`. They fail without the change. Under 
`@CompileStatic`, a `super` call to an extension method in a closure fails on 
master for another reason, with `NoSuchMethodError`; GROOVY-12519 (#3045) fixes 
that, so the closure case here runs in dynamic Groovy and under `@TypeChecked` 
only. 14,936 tests in the `groovy`, `gls`, `bugs`, 
`org.codehaus.groovy.classgen`, `transform`, `runtime`, `reflection`, 
`vmplugin`, `control` and `ast` packages and the stub generator tests pass. 
`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