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

Robert Oschwald commented on GROOVY-9006:
-----------------------------------------

Hit the same today.
{code:java}
if (null != timestamp) 

or 

if (null == timestamp){code}
works btw.

It seems it gets confused by the two equals() methods in java.sql.Timestamp

> Static type checking fails on java.sql.Timestamp when compared to null
> ----------------------------------------------------------------------
>
>                 Key: GROOVY-9006
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9006
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.6
>            Reporter: Devin Rosenbauer
>            Assignee: Eric Milles
>            Priority: Major
>
> The following class fails when compiled by Groovy 2.5.6 (via Gradle). The 
> error is:
> {noformat}
> src/main/groovy/Bug.groovy: 11: [Static type checking] - Reference to method 
> is ambiguous. Cannot choose between [boolean 
> java.sql.Timestamp#equals(java.sql.Timestamp), boolean 
> java.sql.Timestamp#equals(java.lang.Object)]
>  @ line 11, column 13.
>            if (timestamp != null) {
>                ^
> {noformat}
> Class code for {{Bug.groovy}} -
> {code:java}
> import groovy.transform.TypeChecked
> import java.sql.Timestamp
> @TypeChecked
> class Bug {
>     public void bug() {
>         java.sql.Timestamp timestamp = new Timestamp(new Date().getTime());
>         if (timestamp != null) {
>         }
>     }
> }
> {code}
> Expected behavior: Groovy compiles "x != null" without reference to Java's 
> {{equals}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to