From e3b924e3e287baab36693afb92fb9988c56a57a1 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Mon, 21 May 2012 21:25:50 -0700 Subject: SI-5779: Wrong warning message (comparing values of types Float/Double and Number using `==' will always yield false) BoxesRuntime knows how to compare java.lang.Number, so we must not warn. --- test/files/pos/t5779-numeq-warn.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/files/pos/t5779-numeq-warn.scala (limited to 'test/files') diff --git a/test/files/pos/t5779-numeq-warn.scala b/test/files/pos/t5779-numeq-warn.scala new file mode 100644 index 0000000000..76ef2970fd --- /dev/null +++ b/test/files/pos/t5779-numeq-warn.scala @@ -0,0 +1,13 @@ + +object Test { + def main(args: Array[String]) { + val d: Double = (BigInt(1) << 64).toDouble + val f: Float = d.toFloat + val n: java.lang.Number = d.toFloat + assert (d == f) // ok + assert (d == n) // was: comparing values of types Double and Number using `==' will always yield false + assert (n == d) // was: Number and Double are unrelated: they will most likely never compare equal + assert (f == n) + assert (n == f) + } +} -- cgit v1.2.3