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/12/22 11:39:01 UTC
[jira] [Closed] (GROOVY-11014) CompileStatic & Elvis operator: Cannot assign literal value of type (java.lang.Number or java.lang.Comparable) to variable of type double
[ https://issues.apache.org/jira/browse/GROOVY-11014?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-11014.
------------------------------
> CompileStatic & Elvis operator: Cannot assign literal value of type (java.lang.Number or java.lang.Comparable) to variable of type double
> -----------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11014
> URL: https://issues.apache.org/jira/browse/GROOVY-11014
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 4.0.5
> Reporter: Jason Garrett
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 5.0.0-alpha-3, 4.0.16
>
>
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class ElvisLiteralAssign {
> Double x = null
> double y = x?.doubleValue() ?: 0
> } {code}
> This class fails to compile with error: [Static type checking] - Cannot assign value of type (java.lang.Number or java.lang.Comparable) to variable of type double
> This affects at least 4.0.10 and 4.0.11, and does not affect 3.0.16 or 3.0.17.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)