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

Unexpected type mismatch when having conflicting type parameter names

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-2
    • Static Type Checker
    • None

    Description

      I have the following Groovy program

       

      class A<X, T extends Number> {}
      class B<T> {
        A<? extends T, Number> x;
        B(A<? extends T, Number> x) {
          this.x = x;
        }
      }
      

      Actual Behaviour

       

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 5: [Static type checking] - Incompatible generic argument types. Cannot assign A<java.lang.Object, java.lang.Number> to: A<? extends T, java.lang.Number>
       @ line 5, column 14.
             this.x = x;
                      ^1 error
      
      

      Expected Behaviour

      Compile successfully

       

      Tested against master

       

       

       

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: