You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2022/06/20 09:08:00 UTC

[jira] [Commented] (GROOVY-10632) Unable to infer type parameter of recursive method

    [ https://issues.apache.org/jira/browse/GROOVY-10632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556283#comment-17556283 ] 

Thodoris Sotiropoulos commented on GROOVY-10632:
------------------------------------------------

FYI, this is another test program that  triggers the bug. Therefore, recursive method is not a requirement

{code}
class Foo<T> {}

class Test {
  public static <T extends Foo<Short>> T foo() {
    return null;
  }

  public static <T extends Foo<Short>> void bar() {

    Foo<T> x = new Foo<T>(Test.foo());

  }
}
{code}

> Unable to infer type parameter of recursive method
> --------------------------------------------------
>
>                 Key: GROOVY-10632
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10632
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>
> I have the following program
> {code}
> 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;
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> 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
> {code}
> h3. Expected behavior
> Compile successfully
> Tested against master (commit: a976ecdee1f17f7fafc55767de2d857c44d44697)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)