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

Unable to infer type parameter of recursive method

    XMLWordPrintableJSON

Details

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

    Description

      I have the following program

      class A<T> {}
      
      class B<T extends A<String>> {
        B(T x) {}
      }
      
      class Test {
        <T extends A<String>> T test() {
          new B<T>(test());
          return null;
        }
      
      }
      

      Actual behavior

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 9: [Static type checking] - Cannot call B#<init>(T) with arguments [A<T>]
       @ line 9, column 5.
             new B<T>(test());
             ^
      
      1 error
      

      Expected behavior

      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: