[
https://issues.apache.org/jira/browse/GROOVY-7994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15653194#comment-15653194
]
ASF GitHub Bot commented on GROOVY-7994:
----------------------------------------
GitHub user paulk-asert opened a pull request:
https://github.com/apache/groovy/pull/459
GROOVY-7994: Anonymous inner class believes protected method in paren…
…t's superclass returns Object
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paulk-asert/groovy groovy7994
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/459.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #459
----
commit b047e0961032b169c2f884d60f28e1c32e37135d
Author: paulk <[email protected]>
Date: 2016-11-10T06:31:46Z
GROOVY-7994: Anonymous inner class believes protected method in parent's
superclass returns Object
----
> Anonymous inner class believes protected method in parent's superclass
> returns Object
> -------------------------------------------------------------------------------------
>
> Key: GROOVY-7994
> URL: https://issues.apache.org/jira/browse/GROOVY-7994
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.4.7
> Reporter: James Kleeh
>
> The below will execute the constructor on `Other` that takes an `Object`,
> even though `getName()` returns a `String`.
> {code}
> import groovy.transform.CompileStatic
> @CompileStatic
> class Parent {
> protected String getName() {
> "sally"
> }
> }
> @CompileStatic
> class Child extends Parent {
> Inner doSomething() {
> return new Inner() {
> void go() {
> new Other(name)
> }
> }
> }
> }
> @CompileStatic
> class Other {
> Other(Object object) {
> println "called with other"
> }
> Other(String string) {
> println "called with string"
> }
> }
> @CompileStatic
> abstract class Inner {
> abstract void go()
> }
> Inner inner = new Child().doSomething()
> inner.go()
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)