You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/02/10 21:41:00 UTC
[jira] [Closed] (GROOVY-10745) Type not captured correctly (regression in 2.5.18)
[ https://issues.apache.org/jira/browse/GROOVY-10745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10745.
------------------------------
> 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
> Fix For: 2.5.19
>
>
> 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)