diff --git a/tests/pos/i18345.scala b/tests/pos/i18345.scala new file mode 100644 index 000000000000..2064a4ce75e9 --- /dev/null +++ b/tests/pos/i18345.scala @@ -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() +