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

STC computes an imprecise LUB when involving two parameterized types implementing the same interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.11, 4.0.3
    • Static Type Checker
    • None

    Description

      I have the following program

       

      class A {
        void foo(I x) {}
      }
      interface I {}
      interface I2 extends I {}
      class B<T> implements I2 {}
      class C<T> implements I {}
      class Main {
        public static void main(String[] args) {
          (new A()).foo((true) ? new B<String>() : new C<String>());
        }
      }
      

      Actual behaviour

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

      Expected behaviour

      Compile successfully

       

      Tested against master

       

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: