[ https://issues.apache.org/jira/browse/GROOVY-7164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pascal Schumacher closed GROOVY-7164. ------------------------------------- > @CompileStatic transform gives unexpected result for default constructor > ------------------------------------------------------------------------ > > Key: GROOVY-7164 > URL: https://issues.apache.org/jira/browse/GROOVY-7164 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.3.7, 2.4.0-rc-1 > Reporter: Leonard Brünings > Assignee: Cédric Champeau > Fix For: 2.4.5 > > > The following snippet reproduces a type checking error > {code:java} > 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()) > } > } > {code} > {noformat} > 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 > {noformat} > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332)