We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c468843 + a8db298 commit 1f5343cCopy full SHA for 1f5343c
tests/run/i1463.scala
@@ -0,0 +1,26 @@
1
+object Test {
2
+ case object Bob { override def equals(other: Any) = true }
3
+
4
+ class Bob2 {
5
+ override def equals(other: Any) = true
6
+ }
7
+ val Bob2 = new Bob2
8
9
+ def f0(x: Any) = x match { case Bob2 => Bob2 }
10
+ def f1(x: Any) = x match { case Bob => Bob }
11
+ // def f2(x: Any): Bob.type = x match { case x @ Bob => x } // should not type check
12
13
+ def main(args: Array[String]): Unit = {
14
+ assert(f0(Bob2) eq Bob2)
15
+ assert(f0(0) eq Bob2)
16
+ assert(f0(Nil) eq Bob2)
17
18
+ assert(f1(Bob) eq Bob)
19
+ assert(f1(0) eq Bob)
20
+ assert(f1(Nil) eq Bob)
21
22
+ // assert(f2(Bob) eq Bob)
23
+ // assert(f2(0) eq Bob)
24
+ // assert(f2(Nil) eq Bob)
25
26
+}
0 commit comments