Skip to content

Commit 84099a7

Browse files
authored
Test for #18345 (#18349)
Closes #18345
2 parents 70be2df + 072b2e5 commit 84099a7

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)