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

LUB does not work properly when mixing type parameter names and using wildcards

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.5, 3.0.20
    • Static Type Checker
    • None

    Description

      This might be related to GROOVY-10662.

      I have the following program

      class A<T, X> {
      }
      
      class Test<T> {
        void test(A<Double, ? extends T> x) {
          A<Double, ? extends T> y = x;
          A<Double, ? extends T> z = (true) ? y : x;
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 7: [Static type checking] - Incompatible generic argument types. Cannot assign A<java.lang.Double, java.lang.Object> to: A<java.lang.Double, ? extends T>
       @ line 7, column 32.
             A<Double, ? extends T> z = (true) ? y : x;
                                        ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Notes: The bug is triggered when the following conditions hold:

      • The name of the first type parameter of class A matches the type parameter of class Test.
      • We the wildcard type "? extends T" for instantiating the type constructor A on lines 5, 6, 7.

      Tested against master (commit: 1ea7b9619e7a3ec0da9a3e065f78e394206ea632)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: