Skip to content

Commit

Permalink
Backport "Test for #18345" to LTS (#19151)
Browse files Browse the repository at this point in the history
Backports #18349 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
Kordyjan committed Dec 8, 2023
2 parents d4571b7 + 44d5ada commit 468f3be
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 468f3be

Please sign in to comment.