aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/t3150.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pending/run/t3150.scala')
-rw-r--r--tests/pending/run/t3150.scala36
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/pending/run/t3150.scala b/tests/pending/run/t3150.scala
index 034703b5f..dc95af373 100644
--- a/tests/pending/run/t3150.scala
+++ b/tests/pending/run/t3150.scala
@@ -1,10 +1,26 @@
-object Test {
- case object Bob { override def equals(other: Any) = true }
- def f(x: Any) = x match { case Bob => Bob }
-
- def main(args: Array[String]): Unit = {
- assert(f(Bob) eq Bob)
- assert(f(0) eq Bob)
- assert(f(Nil) eq Bob)
- }
-}
+ object Test {
+ case object Bob { override def equals(other: Any) = true }
+
+ class Bob2 {
+ override def equals(other: Any) = true
+ }
+ val Bob2 = new Bob2
+
+ def f0(x: Any) = x match { case Bob2 => Bob2 } // class cast exception at runtime, dotc only
+ def f1(x: Any) = x match { case Bob => Bob } // class cast exception at runtime, dotc only
+ def f2(x: Any): Bob.type = x match { case x @ Bob => x } // class cast exception at runtime, dotc and javac.
+
+ def main(args: Array[String]): Unit = {
+ assert(f0(Bob2) eq Bob2)
+ assert(f0(0) eq Bob2) // only dotty fails here
+ assert(f0(Nil) eq Bob2)
+
+ assert(f1(Bob) eq Bob)
+ assert(f1(0) eq Bob) // only dotty fails here
+ assert(f1(Nil) eq Bob)
+
+ assert(f2(Bob) eq Bob)
+ assert(f2(0) eq Bob) // both dotty and scalac fail here
+ assert(f2(Nil) eq Bob)
+ }
+ }