Skip to content

Commit 1f5343c

Browse files
authored
Merge pull request #3170 from dotty-staging/fix-1463
Fix #1463: add test case
2 parents c468843 + a8db298 commit 1f5343c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/run/i1463.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)