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

Subtyping does not work properly when having bounded type parameter and closure

    XMLWordPrintableJSON

Details

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

    Description

      This is related to GROOVY-10629, GROOVY-10115, GROOVY-10221

      I have the following program

      class B<X, Y extends X> {
        void test() {
          Closure<String> clos = { X x -> x.toString() }
          clos((Y) null);
        }
      }
      

      Actual behaviour

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 4: [Static type checking] - Cannot call closure that accepts [X] with [Y]
       @ line 4, column 9.
             clos((Y) null);
                 ^
      
      1 error
      

      Expected behaviour

      Compile successfully

      Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: