Skip to content

Commit 0d6c926

Browse files
authored
Merge pull request #11528 from dotty-staging/fix-t12237
Add test for t12237
2 parents 7bef33b + cd8c640 commit 0d6c926

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/patmat/t12237.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21: Pattern Match Exhaustivity: Root, PathAndQuery./(_, _), PathAndQuery.===(_, _), PathAndQuery.:&(_, PathAndQuery.===(_, _)), PathAndQuery.+?(_, PathAndQuery.===(_, _))

tests/patmat/t12237.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
sealed trait PathAndQuery
2+
sealed trait Path extends PathAndQuery
3+
sealed trait Query extends PathAndQuery
4+
5+
object PathAndQuery {
6+
case object Root extends Path
7+
case class /(prev: Path, value: String) extends Path
8+
case class ===(k: String, v: String) extends Query
9+
case class :&(prev: Query, next:(===)) extends Query
10+
case class +?(path: Path, next:(===)) extends Query
11+
}
12+
13+
import PathAndQuery._
14+
15+
class Test {
16+
val path = /(/(Root, "page"), "1")
17+
val q1 = ===("k1", "v1")
18+
val q2 = ===("k2", "v2")
19+
val pq = :&(+?(path, q1), q2)
20+
21+
(pq: PathAndQuery) match {
22+
case Root / "page" / "1" => println("match 1")
23+
case Root / "page" / "1" +? ("k1" === "v1") => println("match 2")
24+
case Root / "page" / "1" +? ("k1" === "v1") :& ("k2" === "v2") => println("match 3")
25+
}
26+
}

0 commit comments

Comments
 (0)