Skip to content

Commit

Permalink
Test for #18345 (#18349)
Browse files Browse the repository at this point in the history
Closes #18345
  • Loading branch information
odersky authored Aug 7, 2023
2 parents 70be2df + 072b2e5 commit 84099a7
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 84099a7

Please sign in to comment.