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

Unable to call parameterized function that contains type variables with recursive bounds

    XMLWordPrintableJSON

Details

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

    Description

      I have the following program that uses the guava lib.

      class Main {
        static final void test() {
          String arg1 = null;
          Number arg2 = null;
          com.google.common.collect.ImmutableSortedMap.<String, Number>of(arg1, arg2);
        }
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Main.groovy: 8: [Static type checking] - Cannot call <K extends java.lang.Comparable<? super K>,V> com.google.common.collect.ImmutableSortedMap#of(K, V) with arguments [java.lang.String, java.lang.Number]
       @ line 8, column 5.
             com.google.common.collect.ImmutableSortedMap.<String, Number>of(arg1, arg2);
             ^
      
      1 error
      
      

      Expected behavior

      Compile successfully

      Notes

      Tested against master (commit: 7a118010591ca469f0394d8d6946b44201d04ebd)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: