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 2022/07/19 21:55:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=17568755#comment-17568755 ] 

Eric Milles commented on GROOVY-10282:
--------------------------------------

https://github.com/apache/groovy/commit/e45882e5e7dd89322d4f35e717b23f966ee41613

> 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, 3.0.11
>
>          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.10#820010)