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

Regression in STC generics solution

    XMLWordPrintableJSON

Details

    Description

      The following code, which works in 4.0.14 and below, incorrectly produces an error in 4.0.16.

      Expected result: mapTry(Option::get) unwraps the Try<Option<Integer>> into a Try<Integer>

      https://www.javadoc.io/doc/io.vavr/vavr/0.10.4/io/vavr/control/Try.html

      Actual:

      [Static type checking] - Incompatible generic argument types. Cannot assign io.vavr.control.Try<io.vavr.control.Option<java.lang.Integer>> to: io.vavr.control.Try<java.lang.Integer>
      
      import groovy.transform.CompileStatic
      import io.vavr.control.Option
      import io.vavr.control.Try
      
      @Grab('io.vavr:vavr:0.10.4')
      @CompileStatic
      class Repro {
          Option<Integer> option() {
              Option.of(3)
          }
      
          Try<Integer> repro() {
              Try.of { option() }
                  .mapTry(Option::get)
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              chrylis Christopher Smith
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: