[ https://issues.apache.org/jira/browse/GROOVY-11014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17782232#comment-17782232 ]
Eric Milles edited comment on GROOVY-11014 at 11/2/23 5:12 PM: --------------------------------------------------------------- https://github.com/apache/groovy/commit/0f6185fd64bc7082f42c7c4b411f45bca008f10b This adds back the handling of wrapper type vs. primitive. It leaves wrapper vs. wrapper as returning "(Number or Comparable)" (see GROOVY-8965). I'm not sure it properly handles number literals that will fit within the range of the boxed type. For example "def n = flag ? (short)1234 : 0" is of type {{short}} in Java IIRC. was (Author: emilles): https://github.com/apache/groovy/commit/0f6185fd64bc7082f42c7c4b411f45bca008f10b This adds back the handling of wrapper type vs. primitive. It leaves wrapper vs. wrapper as returning "(Number or Comparable)" (see GROOVY-8965). I'm not sure it properly handles number literals that will fit within the range of the boxed type properly. For example "def n = flag ? (short)1234 : 0" is of type {{short}} in Java IIRC. > 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 > > > {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)