Skip to content

Commit 0221744

Browse files
committed
Box arguments of type applications
This required a change in `lists.scala`, where capture sets buried to the right had to be repeated on the whole type. I believe there is no desugaring yet that would do these things automatically.
1 parent 54c0ebf commit 0221744

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ extends tpd.TreeTraverser:
333333
mapOver(t)
334334
end SubstParams
335335

336-
private def transformTT(tree: TypeTree, boxed: Boolean)(using Context) =
336+
private def transformTT(tree: TypeTree, boxed: Boolean)(using Context): Unit =
337337
tree.rememberType(
338338
if tree.isInstanceOf[InferredTypeTree]
339339
then transformInferredType(tree.tpe, boxed)
@@ -349,6 +349,10 @@ extends tpd.TreeTraverser:
349349
case tree @ ValDef(_, tpt: TypeTree, _) if tree.symbol.is(Mutable) =>
350350
transformTT(tpt, boxed = true)
351351
traverse(tree.rhs)
352+
case tree @ TypeApply(fn, args) =>
353+
traverse(fn)
354+
for case arg: TypeTree <- args do
355+
transformTT(arg, boxed = true)
352356
case _ =>
353357
traverseChildren(tree)
354358
tree match

tests/pos-custom-args/captures/lists.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test(c: Cap, d: Cap, e: Cap) =
5050
val eff2 = [A] => (x: A) => if x == e then x else x
5151

5252
val a0 = identity[{d, y} Cap -> Unit]
53-
val a0c: ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = a0
53+
val a0c: {d, y} ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = a0
5454
val a1 = zs.map[{d, y} Cap -> Unit](a0)
5555
val a1c: LIST[{d, y} Cap -> Unit] = a1
5656
val a2 = zs.map[{d, y} Cap -> Unit](identity[{d, y} Cap -> Unit])
@@ -65,7 +65,7 @@ def test(c: Cap, d: Cap, e: Cap) =
6565
val a6c: LIST[{d, c} Cap -> Unit] = a6
6666

6767
val b0 = eff[{d, y} Cap -> Unit]
68-
val b0c: {e} ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = b0
68+
val b0c: {e, d, y} ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = b0
6969
val b1 = zs.map[{d, y} Cap -> Unit](a0)
7070
val b1c: {e} LIST[{d, y} Cap -> Unit] = b1
7171
val b2 = zs.map[{d, y} Cap -> Unit](eff[{d, y} Cap -> Unit])
@@ -80,7 +80,7 @@ def test(c: Cap, d: Cap, e: Cap) =
8080
val b6c: {e} LIST[{d, c} Cap -> Unit] = b6
8181

8282
val c0 = eff2[{d, y} Cap -> Unit]
83-
val c0c: {e} ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = c0
83+
val c0c: {e, d, y} ({d, y} Cap -> Unit) -> {d, y} Cap -> Unit = c0
8484
val c1 = zs.map[{d, y} Cap -> Unit](a0)
8585
val c1c: {e} LIST[{d, y} Cap -> Unit] = c1
8686
val c2 = zs.map[{d, y} Cap -> Unit](eff2[{d, y} Cap -> Unit])

0 commit comments

Comments
 (0)