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

Cannot assign type parameter whose bound is a parameterized type that takes a wildcard

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

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

    Description

      I have the following program

      class A<T1, T2> {}
      
      class B<T1 extends Number, T2 extends A<C, ? extends T1>> {
        T2 f;
      
        B(T2 f) {
          this.f  = f;
        }
      }
      
      class C {}
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 7: [Static type checking] - Cannot assign value of type A<C, ? extends java.lang.Number<T1 extends java.lang.Number>> to variable of type T2
       @ line 7, column 15.
             this.f  = f;
                       ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment