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 2023/04/15 15:52:00 UTC

[jira] [Updated] (GROOVY-10992) Unexpected type mismatch when calling a parameterized function with a bounded type parameter

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

Eric Milles updated GROOVY-10992:
---------------------------------
    Priority: Minor  (was: Major)

> Unexpected type mismatch when calling a parameterized function with a bounded type parameter
> --------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10992
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10992
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Priority: Minor
>
> Possible regression? Groovyc 4.0.10 compiles the program
> I have the following program
> {code}
> import java.util.function.Supplier;
> import java.util.function.BinaryOperator;
> import java.util.stream.Stream;
> class Main {
>   static final <X extends Number> void test() {
>     Supplier<Stream<X>> x = null;
>     X y = null;
>     BinaryOperator<X> z = null;
>     X result = x.get().reduce(y, z);
>   }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 11: [Static type checking] - Cannot call java.util.stream.Stream#reduce(X, java.util.function.BinaryOperator<X extends java.lang.Number>) with arguments [X, java.util.function.BinaryOperator<X>]
>  @ line 11, column 16.
>        X result = x.get().reduce(y, z);
>                   ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> Notes: The type parameter X should have an upper bound in order to trigger the error.
> Tested against master (commit: a29ce1ce64d565526b70e145ace665dd0617ec9b)



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