Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6882

STC: AIC cannot resolve overridden method of outer class

    XMLWordPrintableJSON

Details

    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();
      

      Attachments

        Activity

          People

            emilles Eric Milles
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h