[ 
https://issues.apache.org/jira/browse/GROOVY-7164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14703713#comment-14703713
 ] 

ASF GitHub Bot commented on GROOVY-7164:
----------------------------------------

GitHub user shils opened a pull request:

    https://github.com/apache/incubator-groovy/pull/90

    GROOVY-7164 Check constructor map args on setter parameter type when …

    …outside of declaring class

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shils/incubator-groovy GROOVY-7164

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-groovy/pull/90.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #90
    
----
commit 2ab8214fbc7323fd79a025502e5afa7fc9ea1e8c
Author: Shil Sinha <shil.si...@gmail.com>
Date:   2015-08-19T20:40:15Z

    GROOVY-7164 Check constructor map args on setter parameter type when 
outside of declaring class

----


> @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
>
> 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)

Reply via email to