Skip to content

Commit 9254ef6

Browse files
Merge pull request #11463 from dotty-staging/fix-11438
Fix #11438: fix typo in match type docs snippet
2 parents a633e93 + 1fb3271 commit 9254ef6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-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
@@ -67,7 +67,7 @@ use of the match type as the return type):
6767
def leafElem[X](x: X): LeafElem[X] = x match
6868
case x: String => x.charAt(0)
6969
case x: Array[t] => leafElem(x(9))
70-
case x: Iterable[t] => leafElem(x.next())
70+
case x: Iterable[t] => leafElem(x.head)
7171
case x: AnyVal => x
7272
```
7373

tests/pos/11463.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type LeafElem[X] = X match
2+
case String => Char
3+
case Array[t] => LeafElem[t]
4+
case Iterable[t] => LeafElem[t]
5+
case AnyVal => X
6+
7+
def leafElem[X](x: X): LeafElem[X] = x match
8+
case x: String => x.charAt(0)
9+
case x: Array[t] => leafElem(x(9))
10+
case x: Iterable[t] => leafElem(x.head)
11+
case x: AnyVal => x

0 commit comments

Comments
 (0)