Skip to content

Commit

Permalink
Test for #18345
Browse files Browse the repository at this point in the history
Closes #18345

[Cherry-picked 072b2e5]
  • Loading branch information
odersky authored and Kordyjan committed Dec 1, 2023
1 parent 4115f71 commit f423521
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/pos/i18345.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extension (vec: Seq[Int])
def iterate[T](body: (() => Int) => T): T =
val iterator = vec.iterator
body(() => iterator.nextOption().getOrElse(0))

def withSequence[T](n: Int)(body: Seq[Int] => T): T =
body((0 to n))

def test =

withSequence(2):
_.iterate: next =>
next() + next() + next() + next()

withSequence(2):
_.iterate:
next =>
next() + next() + next() + next()

withSequence(2): x =>
x.iterate:
next =>
next() + next() + next() + next()

withSequence(2): x =>
x.iterate: next =>
next() + next() + next() + next()

0 comments on commit f423521

Please sign in to comment.