Thodoris Sotiropoulos created GROOVY-10227:
----------------------------------------------

             Summary: STC computes an imprecise LUB when involving two 
parameterized types implementing the same interface
                 Key: GROOVY-10227
                 URL: https://issues.apache.org/jira/browse/GROOVY-10227
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


I have the following program

 
{code:java}
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>());
  }
}
{code}
h3. Actual behaviour
{code:java}
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

{code}
h3. Expected behaviour

Compile successfully

 

Tested against master

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to