[
https://issues.apache.org/jira/browse/GROOVY-11241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17793911#comment-17793911
]
Eric Milles edited comment on GROOVY-11241 at 1/4/24 9:19 PM:
--------------------------------------------------------------
I don't have a solution yet for Groovy 4. It is mixing "T" from {{Option}} and
"T" from {{Try}}. In 4.0.14 this worked in your favor, resulting in
"T=Integer". 4.0.16 gets "T=Option<Integer>" at the point of
{{mapTry(Option::get)}} which is incorrect.
If I try and stop the mixing at the same point where the Groovy 5 fix went in,
it cannot work out "T=Integer" and ends up with "T=Object" which is the erasure
of "T" from {{Option}}.
Update: it is fixed
was (Author: emilles):
I don't have a solution yet for Groovy 4. It is mixing "T" from {{Option}} and
"T" from {{Try}}. In 4.0.14 this worked in your favor, resulting in
"T=Integer". 4.0.16 gets "T=Option<Integer>" at the point of
{{mapTry(Option::get)}} which is incorrect.
If I try and stop the mixing at the same point where the Groovy 5 fix went in,
it cannot work out "T=Integer" and ends up with "T=Object" which is the erasure
of "T" from {{Option}}.
> Regression in STC generics solution
> -----------------------------------
>
> Key: GROOVY-11241
> URL: https://issues.apache.org/jira/browse/GROOVY-11241
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 4.0.16
> Reporter: Christopher Smith
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.20, 5.0.0-alpha-4, 4.0.17
>
>
> 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:
> {code}
> [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>
> {code}
> {code}
> 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)
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)