Skip to content

Commit 5c2f658

Browse files
Merge pull request #6468 from dotty-staging/fix-#5625
Fix #5625: Update documentation
2 parents d6f4cc3 + e664e9e commit 5c2f658

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

docs/docs/reference/new-types/match-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Match types can form part of recursive type definitions. Example:
3434
case String => Char
3535
case Array[t] => LeafElem[t]
3636
case Iterable[t] => LeafElem[t]
37-
case t <: AnyVal => t
37+
case AnyVal => X
3838
}
3939
```
4040
Recursive match type definitions can also be given an upper bound, like this:

tests/pos/i5625.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
3+
type LeafElem[X] = X match {
4+
case String => Char
5+
case Array[t] => LeafElem[t]
6+
case Iterable[t] => LeafElem[t]
7+
case AnyVal => X
8+
}
9+
10+
the[LeafElem[String] =:= Char]
11+
the[LeafElem[Array[Int]] =:= Int]
12+
the[LeafElem[Iterable[Int]] =:= Int]
13+
the[LeafElem[Int] =:= Int]
14+
}

tests/pos/i5625b.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
object Test {
2+
3+
type AV[t <: AnyVal] = t
4+
5+
type LeafElem[X] = X match {
6+
case String => Char
7+
case Array[t] => LeafElem[t]
8+
case Iterable[t] => LeafElem[t]
9+
case AV[t] => t
10+
}
11+
12+
the[LeafElem[String] =:= Char]
13+
the[LeafElem[Array[Int]] =:= Int]
14+
the[LeafElem[Iterable[Int]] =:= Int]
15+
the[LeafElem[Int] =:= Int]
16+
}

0 commit comments

Comments
 (0)