Jason Garrett created GROOVY-11006:
--------------------------------------
Summary: CompileStatic: cannot implicitly call double setter with
BigDecimal literal
Key: GROOVY-11006
URL: https://issues.apache.org/jira/browse/GROOVY-11006
Project: Groovy
Issue Type: Bug
Components: Compiler
Affects Versions: 3.0.17
Reporter: Jason Garrett
When a class declares a double property and setter for it:
{code:java}
class DoubleWithSetter {
protected double myDouble
void setMyDouble(double val) {
this.myDouble = val
}
} {code}
A statically-compiled subclass cannot "assign" a BigDecimal literal to that
property:
{code:java}
import groovy.transform.CompileStatic
@CompileStatic
class BigDecimalImplicitDoubleSetter extends DoubleWithSetter {
void doStuff() {
double doubleVar = 0.0 // works
myDouble = doubleVar // works
myDouble = 0.0 // [Static type checking] - Cannot assign value
of type java.math.BigDecimal to variable of type double
}
} {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)