Skip to content

Commit

Permalink
Merge pull request scala#11463 from dotty-staging/fix-11438
Browse files Browse the repository at this point in the history
Fix scala#11438: fix typo in match type docs snippet
  • Loading branch information
OlivierBlanvillain authored Feb 18, 2021
2 parents a633e93 + 1fb3271 commit 9254ef6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/docs/reference/new-types/match-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use of the match type as the return type):
def leafElem[X](x: X): LeafElem[X] = x match
case x: String => x.charAt(0)
case x: Array[t] => leafElem(x(9))
case x: Iterable[t] => leafElem(x.next())
case x: Iterable[t] => leafElem(x.head)
case x: AnyVal => x
```

Expand Down
11 changes: 11 additions & 0 deletions tests/pos/11463.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type LeafElem[X] = X match
case String => Char
case Array[t] => LeafElem[t]
case Iterable[t] => LeafElem[t]
case AnyVal => X

def leafElem[X](x: X): LeafElem[X] = x match
case x: String => x.charAt(0)
case x: Array[t] => leafElem(x(9))
case x: Iterable[t] => leafElem(x.head)
case x: AnyVal => x

0 comments on commit 9254ef6

Please sign in to comment.