[jira] [Updated] (GROOVY-6882) STC: AIC cannot resolve overridden method of outer class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (GROOVY-6882) STC: AIC cannot resolve overridden method of outer class

Eric Milles (Jira)

     [ 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)