Skip to content

Commit 46c680c

Browse files
Add test case for unapply on zero arity case class
1 parent 2923d32 commit 46c680c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/run/zero-arity-case-class.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
case class Foo()
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
assert(Foo.unapply(Foo()) == true)
6+
7+
// unapply generate by scalac are `_ != null`,
8+
// dotty returns true in all cases
9+
assert(Foo.unapply(null) == true)
10+
11+
Foo() match {
12+
case Foo() => ()
13+
case _ => ???
14+
}
15+
16+
Foo() match {
17+
case _: Foo => ()
18+
case _ => ???
19+
}
20+
21+
(Foo(): Any) match {
22+
case Foo() => ()
23+
case _ => ???
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)