We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c7d5f61 commit a2876f7Copy full SHA for a2876f7
tests/pos/Buffer.scala
@@ -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