codeconsole opened a new pull request, #3047:
URL: https://github.com/apache/groovy/pull/3047
When a superclass overloads a setter (`setX(int)` and `setX(String)`) and
the class overrides one of the setters or declares the property, `super.x = v`
in dynamic Groovy and under `@TypeChecked` called the class's own setter, also
in a closure. It now chooses among the superclass's setters, like
`super.setX(v)`. `@CompileStatic` already did.
```groovy
class Base {
void setX(int i) { println "Base int $i" }
void setX(String s) { println "Base String $s" }
}
class Sub extends Base {
void setX(String s) { println "Sub String $s" }
void test() { super.x = 'a' } // printed "Sub String a"; now "Base
String a"
}
```
Split out of #3044.
## How
A property with several setters is a `MultipleSetterProperty`, whose
`setProperty` calls the setter by name with ordinary dispatch, so for `super`
it reached the class's own setter. `MetaClassImpl.setProperty` now calls the
setter as a super call.
## Tests
`groovy.ThisAndSuperTest`, for a class that declares the property and one
that overrides a setter, in all three modes, and in a closure in dynamic Groovy
and under `@TypeChecked`. 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. `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]