Skip to content

Commit a2876f7

Browse files
committed
Another test
1 parent c7d5f61 commit a2876f7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/pos/Buffer.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import language.experimental.captureChecking
2+
3+
// Extract of the problem in collection.mutable.Buffers
4+
trait Buffer[A]:
5+
6+
def apply(i: Int): A = ???
7+
8+
def flatMapInPlace(f: A => IterableOnce[A]^): this.type = {
9+
val g = f
10+
val s = 10
11+
// capture checking: we need the copy since we box/unbox on g* on the next line
12+
// TODO: This looks fishy, need to investigate
13+
// Alternative would be to mark `f` as @unbox. It's not inferred
14+
// since `^ appears in a function result, not under a box.
15+
val newElems = new Array[(IterableOnce[A]^{f})](s)
16+
var i = 0
17+
while i < s do
18+
val x = g(this(i))
19+
newElems(i) = x
20+
i += 1
21+
this
22+
}

0 commit comments

Comments
 (0)