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

Eric Milles updated GROOVY-11013:
---------------------------------
    Fix Version/s: 3.0.18

> Fail to substitute type when having SAM type with generics
> ----------------------------------------------------------
>
>                 Key: GROOVY-11013
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11013
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.18, 4.0.13
>
>
> I have the following program
> {code}
> import java.util.*;
> @FunctionalInterface
> interface Foo<T> {
>   int m(List<T> x);
> }
> class Main {
>   static final void test() {
>     Foo<String> p = (List<String> x) -> 1;
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Main.groovy: 11: [Static type checking] - Expected type java.util.List<T> for 
> lambda parameter: x
>  @ line 11, column 22.
>        Foo<String> p = (List<String> x) -> 1;
>                         ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> h3. Notes
> Tested against master (commit: cdc57551a7cce33ec7031b40753f25c869dcf0cc)
> Test case adapted from the following program that uses the 
> apache-commons-collection4 lib
> {code}
> class Main {
>   static final void test() {
>     org.apache.commons.collections4.sequence.ReplacementsHandler<Number> f = 
> (int x, List<java.io.IOException> y, List<Number> z) -> { } ;
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to