[
https://issues.apache.org/jira/browse/GROOVY-11241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17793768#comment-17793768
]
Eric Milles commented on GROOVY-11241:
--------------------------------------
I'd have to pull down 4.0.14 to see why this passed STC previously. Looking at
the current implementation, it appears you may have slipped through a crack
before. The type of the {{Option::get}} expression by itself is {{Closure<T>}}
or {{Closure<Object>}}. Only by incorporating the context of
{{Option<Integer>}} can we work out {{Closure<Integer>}} or
{{CheckedFunction1<Option<Integer>,Integer>}}. I don't think 4.0.14 does this
and certainly 4.0.16 doesn't.
> 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
>
> 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)