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

Miss to check the compatibility of wildcard types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Static Type Checker

    Description

      This might be a known issue / limitation.

      I have the following 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.
        }
      }
      

      Actual behavior

      The code compiles without raising any errors.

      Expected behavior

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

      Notes

      Tested against master

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: