Skip to content

Commit 4d8fb69

Browse files
oderskyKordyjan
authored andcommitted
Test for #18345
Closes #18345 [Cherry-picked 072b2e5]
1 parent de7638b commit 4d8fb69

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/pos/i18345.scala

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extension (vec: Seq[Int])
2+
def iterate[T](body: (() => Int) => T): T =
3+
val iterator = vec.iterator
4+
body(() => iterator.nextOption().getOrElse(0))
5+
6+
def withSequence[T](n: Int)(body: Seq[Int] => T): T =
7+
body((0 to n))
8+
9+
def test =
10+
11+
withSequence(2):
12+
_.iterate: next =>
13+
next() + next() + next() + next()
14+
15+
withSequence(2):
16+
_.iterate:
17+
next =>
18+
next() + next() + next() + next()
19+
20+
withSequence(2): x =>
21+
x.iterate:
22+
next =>
23+
next() + next() + next() + next()
24+
25+
withSequence(2): x =>
26+
x.iterate: next =>
27+
next() + next() + next() + next()
28+

0 commit comments

Comments
 (0)