Thodoris Sotiropoulos created GROOVY-11115:
----------------------------------------------

             Summary: Miss to check the compatibility of wildcard types
                 Key: GROOVY-11115
                 URL: https://issues.apache.org/jira/browse/GROOVY-11115
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
            Reporter: Thodoris Sotiropoulos


This might be a known issue / limitation.

I have the following code

{code}
import java.util.*

class Main {
  static final void test() {
    List<? extends Number> list = new LinkedList<Number>();
    List<Number> x = list; // types are not compatible.
    List<Number> y = (List<? extends Object>) null // types are not compatible;
    list.add(1); // method call is not permitted.
  }
}
{code}

h3. Actual behavior

The code compiles without raising any errors.

h3. Expected behavior

The compiler should have rejected the program by raising three type errors.

h3. Notes

Tested against master



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to