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

Unexpected type mismatch when having bounded type parameters

    XMLWordPrintableJSON

Details

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

    Description

      This might be related to GROOVY-10629.

      I have the following program:

      class Main {
        static final <U extends Number, H extends U> void test() {
          def x = java.util.Collections.<H, H>emptyNavigableMap().ceilingKey((H) null);
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 3: [Static type checking] - Cannot call java.util.NavigableMap#ceilingKey(H) with arguments [H]
       @ line 3, column 13.
             def x = java.util.Collections.<H, H>emptyNavigableMap().ceilingKey((H) null);
                     ^
      
      1 error
      

      Expected behavior

      Compile successfully

      Tested against master (commit: 72cae725137e3a610b94e6927b18587c439f6f9b)

      Attachments

        Activity

          People

            Unassigned Unassigned
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: