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

Unexpected compile-time error when combining closures and bounded type parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.2
    • Static Type Checker
    • None

    Description

      Program

       

      class A<T1, T2 extends T1> {
        void foo() {
          def cls1 = { T2 x -> "" }
          Closure<T2> cls2 = { T2 x -> x }
          cls1(cls2((T2) null))
        }
      }
      

      Actual Behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 5: [Static type checking] - Cannot call closure that accepts [T2] with [T1]
       @ line 5, column 9.
             cls1(cls2((T2) null))
                 ^1 error
      
      

      Expected Behavior

      Compile successfully

       

      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: