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

Fail to infer type argument of parameterized function

    XMLWordPrintableJSON

Details

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

    Description

      I have the following program

      class Foo<X> {}
      
      class Test {
        static void test() {
          m(false, new Foo<>());
        }
      
        static <T> void m(T x1, Foo<T> x2) {}
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 6: [Static type checking] - Cannot call <T> Test#m(T, Foo<T>) with arguments [boolean, Foo<T>]
       @ line 6, column 5.
             m(false, new Foo<>());
             ^
      
      1 error
      

      Expected behavior

      Compile successfully

      note: The issues occurs only when the type parameters of class Foo and method m have different names.

      Tested against master (commit: d7fa923bed20945074a41c54cce5133cc2ab63a0)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: