Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0-rc-1
-
None
Description
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:
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();