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

Unable to resolve method after LUB operator

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      interface I {
        int m(int x);
      }
      
      abstract class A implements I {
      }
      
      class B<T> extends A {
        public int m(int x) {
          return x + 1;
        }
      }
      
      public class C<T> extends A {
        public int m(int x) {
          return x - 1;
        }
      }
      
      class Test {
        void test() {
          C<String> x = null;
          int y = 1;
          ((true) ? x : new B<String>()).m(y);
        }
        
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 26: [Static type checking] - Cannot find matching method A#m(int). Please check if the declared type is correct and if the method exists.
       @ line 26, column 5.
             ((true) ? x : new B<String>()).m(y);
             ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: