You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/11/20 16:37:00 UTC
[jira] [Updated] (GROOVY-6882) STC: AIC cannot resolve overridden
method of outer class
[ https://issues.apache.org/jira/browse/GROOVY-6882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-6882:
--------------------------------
Summary: STC: AIC cannot resolve overridden method of outer class (was: Cannot override method in some cases in anonymous inner classes with @CompileStatic)
> STC: AIC cannot resolve overridden method of outer class
> --------------------------------------------------------
>
> Key: GROOVY-6882
> URL: https://issues.apache.org/jira/browse/GROOVY-6882
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.0-rc-1
> Reporter: Cédric Champeau
> Assignee: Eric Milles
> Priority: Major
>
> Originally reported on StackOverflow: http://stackoverflow.com/questions/24321109/is-threre-any-way-to-ues-override-method-in-anonymous-class-on-groovy-compilest
> This fails with an ambiguous method error:
> {code}
> import groovy.transform.CompileStatic;
> interface HelloWorld {
> public void greet();
> }
> class HelloWorldAnonymousClassesParents {
> public void hi() {
> println "hi"
> }
> }
> @CompileStatic
> public class HelloWorldAnonymousClasses extends HelloWorldAnonymousClassesParents {
> public void hi() {
> System.out.println("hihi ");
> }
> public void sayHello() {
> HelloWorld spanishGreeting = new HelloWorld() {
> public void greet() {
> hi() //<- here [Static type checking] - Reference to method is ambiguous error
> System.out.println("spanishGreeting");
> }
> };
> spanishGreeting.greet();
> hi()
> }
> }
> def myApp = new HelloWorldAnonymousClasses();
> myApp.sayHello();
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)