Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10282

STC: false positive for BiFunction and BinaryOperator with same type parameter

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.CompileStatic
      String foo() {
        def integers = java.util.stream.IntStream.range(0, 10).boxed()
        integers.reduce('', (s, i) -> s + '-', String::concat)
      }
      

      reduce has the following signature in java.util.stream.Stream:

      <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner);
      

      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.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h