ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

== check produces NPE on objects with overridden equals() #291

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following code runs fine in Groovy but leads to an NPE in Groovy++:

Foo x = null
println (x == new Foo())

class Foo {
  boolean equals(o) {
    return this == o
  }
}

Original issue reported on code.google.com by gromop...@gmail.com on 13 Aug 2010 at 7:50

GoogleCodeExporter commented 8 years ago
Yes, the behavior is like Java here instead of groovy.

@Alex, if we want to be like groovy here, instead of binding the call to 
Foo.equals, we may need to dispatch "equals" call to DGMPP.equals(), which can 
do the null checks first and then call Foo.equals(), if needed.

So, do we special case "equals" in method selection logic to always dispatch it 
to DGMPP? Or, is there a cleaner way of achieving it?

Original comment by roshanda...@gmail.com on 14 Aug 2010 at 9:29

GoogleCodeExporter commented 8 years ago

Original comment by alex.tka...@gmail.com on 1 Sep 2010 at 9:40