Skip to content

Commit f1809bd

Browse files
committed
Fix t10100: add test
1 parent 2e377ca commit f1809bd

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/patmat/t10100.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12: Pattern Match Exhaustivity: (_, FancyFoo(_))

tests/patmat/t10100.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
sealed trait Foo {
2+
val index: Int
3+
}
4+
5+
case class BasicFoo(index: Int) extends Foo
6+
7+
class NonExhaustive {
8+
case class FancyFoo(index: Int) extends Foo
9+
10+
def convert(foos: Vector[Foo]): Vector[Int] = {
11+
foos.foldLeft(Vector.empty[Int]) {
12+
case (acc, basic: BasicFoo) => acc :+ basic.index
13+
case (acc, fancy: FancyFoo) => acc :+ fancy.index
14+
}
15+
}
16+
}
17+
18+
@main
19+
def Test = {
20+
val a = new NonExhaustive
21+
val b = new NonExhaustive
22+
23+
val fa: Foo = a.FancyFoo(3)
24+
val fb: Foo = b.FancyFoo(4)
25+
26+
a.convert(Vector(fa, fb))
27+
}

0 commit comments

Comments
 (0)