summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Maier <ingo.maier@epfl.ch>2009-09-23 10:12:32 +0000
committerIngo Maier <ingo.maier@epfl.ch>2009-09-23 10:12:32 +0000
commitdc65ebea9e2e5953a23a11c4df87d0fd7c81f19b (patch)
treec338610aa5d662fc7722622d7c0ffcebbad566b4
parent9e54361343f80925ab7be84239ce37fb021bd7b9 (diff)
downloadscala-dc65ebea9e2e5953a23a11c4df87d0fd7c81f19b.tar.gz
scala-dc65ebea9e2e5953a23a11c4df87d0fd7c81f19b.tar.bz2
scala-dc65ebea9e2e5953a23a11c4df87d0fd7c81f19b.zip
Proxy.equals catches null case (fix for #2366)
-rw-r--r--src/library/scala/Proxy.scala4
-rw-r--r--test/files/run/proxy.check4
-rw-r--r--test/files/run/proxy.scala9
3 files changed, 16 insertions, 1 deletions
diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala
index 4c890c828d..18b08d55a2 100644
--- a/src/library/scala/Proxy.scala
+++ b/src/library/scala/Proxy.scala
@@ -25,6 +25,8 @@ import Predef._
trait Proxy {
def self: Any
override def hashCode: Int = self.hashCode
- override def equals(that: Any): Boolean = that equals self
+ override def equals(that: Any): Boolean =
+ if(that == null) false
+ else that equals self
override def toString: String = self.toString
}
diff --git a/test/files/run/proxy.check b/test/files/run/proxy.check
new file mode 100644
index 0000000000..f311ce0361
--- /dev/null
+++ b/test/files/run/proxy.check
@@ -0,0 +1,4 @@
+false
+true
+false
+false \ No newline at end of file
diff --git a/test/files/run/proxy.scala b/test/files/run/proxy.scala
new file mode 100644
index 0000000000..d9c7bcf69f
--- /dev/null
+++ b/test/files/run/proxy.scala
@@ -0,0 +1,9 @@
+object Test extends Application {
+ val p = new Proxy {
+ def self = 2
+ }
+ println(p equals 1)
+ println(p equals 2)
+ println(p equals 3)
+ println(p equals null)
+} \ No newline at end of file