You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/02/01 23:19:06 UTC
[jira] [Closed] (GROOVY-7994) Anonymous inner class believes
protected method in parent's superclass returns Object
[ https://issues.apache.org/jira/browse/GROOVY-7994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-7994.
-----------------------------
> 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
> Assignee: Paul King
> Fix For: 2.4.8
>
>
> 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.15#6346)