You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:33:01 UTC
[jira] [Closed] (GROOVY-10282) STC: false positive for BiFunction and BinaryOperator with same type parameter
[ https://issues.apache.org/jira/browse/GROOVY-10282?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10282.
------------------------------
> STC: false positive for BiFunction and BinaryOperator with same type parameter
> ------------------------------------------------------------------------------
>
> Key: GROOVY-10282
> URL: https://issues.apache.org/jira/browse/GROOVY-10282
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 4.0.0-beta-1
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-2
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> String foo() {
> def integers = java.util.stream.IntStream.range(0, 10).boxed()
> integers.reduce('', (s, i) -> s + '-', String::concat)
> }
> {code}
> {{reduce}} has the following signature in {{java.util.stream.Stream}}:
> {code:java}
> <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner);
> {code}
> The type parameter {{U}} is shared between the accumulator and combiner and should be resolved to {{java.lang.String}}. However, {{GenericsUtils#parameterizeSAM}} is producing {{java.lang.Integer}} as the return type since that is what is associated with {{T}} in this context.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)