[
https://issues.apache.org/jira/browse/GROOVY-10745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles reassigned GROOVY-10745:
------------------------------------
Assignee: Eric Milles
> Type not captured correctly (regression in 2.5.18)
> --------------------------------------------------
>
> Key: GROOVY-10745
> URL: https://issues.apache.org/jira/browse/GROOVY-10745
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Affects Versions: 2.5.18
> Reporter: Mauro Molinari
> Assignee: Eric Milles
> Priority: Major
>
> Consider this:
> {code:groovy}
> package test2
> import groovy.transform.CompileStatic
> @CompileStatic
> class OptionalTest {
>
> void foo() {
> Optional.of(bar()).orElse(Collections.emptyMap());
> }
>
> Map bar() {
> new HashMap()
> }
> } {code}
> This compiles fine in 2.5.17, 2.5.16, etc., but fails with 2.5.18:
> {noformat}
> [Static type checking] - Cannot call java.util.Optional
> <java.util.Map>#orElse(java.util.Map) with arguments [java.lang.Object]
> @ line 9, column 3.
> Optional.of(bar()).orElse(Collections.emptyMap());
> ^
> 1 error
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)