Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.7, 2.4.0-rc-1
-
None
Description
The following snippet reproduces a type checking error
import groovy.transform.CompileStatic @CompileStatic class Test { private long timestamp Date getTimestamp() { return timestamp ? new Date(timestamp) : null } void setTimestamp (Date timestamp) { this.timestamp = timestamp.time } def main() { new Test(timestamp: new Date()) } }
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 16: [Static type checking] - Cannot assign value of type java.util.Date to variable of type long @ line 16, column 27. new Test(timestamp: new Date()) ^ 1 error
This is quite unexpected it should use the type of the getter and setter for the validation since they are used later on to assign the value and not the type of the underlying field.