Thodoris Sotiropoulos created GROOVY-10633:
----------------------------------------------

             Summary: Invalid type substitution when encountering bounded type 
parameter and the diamond operator
                 Key: GROOVY-10633
                 URL: https://issues.apache.org/jira/browse/GROOVY-10633
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


This bug is a regression.

I have the following program:

{code}
class A<T, Y> {
  B<Y> f;
  A(B<Y> x, T y) {}
}

class B<T> {
  void m(T x) {}
}

class Test {
  <T extends Number> void test() {
    def x = new B<T>();
    new A<>(x, "").f.m((T) null);
  }
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 13: [Static type checking] - Cannot find matching method B#m(T). 
Please check if the declared type is correct and if the method exists.
 @ line 13, column 5.
       new A<>(x, "").f.m((T) null);
       ^

1 error
{code}

h3. Expected behaviour 

Compile successfully

Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to