You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/02 15:01:00 UTC

[jira] [Resolved] (GROOVY-9945) STC: Cannot find matching method when using Generics

     [ https://issues.apache.org/jira/browse/GROOVY-9945?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-9945.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> STC: Cannot find matching method when using Generics
> ----------------------------------------------------
>
>                 Key: GROOVY-9945
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9945
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.0-alpha-2
>            Reporter: Stefanos Chaliasos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> I have the following Groovy program.
> {code:groovy}
> interface I1<X, Y> {}
> interface I2 extends I1<Character, Character> {}
> class Foo<X, Y> implements I2 {
>   public void foo(X x, Y y) {}
> }
> class Bar<X, Y> extends Foo<X, Y> {}
> @groovy.transform.TypeChecked
> class Main {
>   public static void foo() {
>     new Bar<Float, Integer>().foo((Float) 1.4, -1)
>   }
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 14: [Static type checking] - Cannot find matching method Bar#foo(java.lang.Float, java.lang.Integer). Please check if the declared type is correct and if the method exists.
>  @ line 14, column 5.
>        new Bar<Float, Integer>().foo((Float) 1.4, -1)
>        ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)