We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a633e93 + 1fb3271 commit 9254ef6Copy full SHA for 9254ef6
docs/docs/reference/new-types/match-types.md
@@ -67,7 +67,7 @@ use of the match type as the return type):
67
def leafElem[X](x: X): LeafElem[X] = x match
68
case x: String => x.charAt(0)
69
case x: Array[t] => leafElem(x(9))
70
- case x: Iterable[t] => leafElem(x.next())
+ case x: Iterable[t] => leafElem(x.head)
71
case x: AnyVal => x
72
```
73
tests/pos/11463.scala
@@ -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
11
+ case x: AnyVal => x
0 commit comments