Skip to content

Commit 54c0ebf

Browse files
committed
Always print boxes (for now)
It's a necessary measure to diagnose mishandlings of boxes faster.
1 parent 275218d commit 54c0ebf

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ extends tpd.TreeTraverser:
339339
then transformInferredType(tree.tpe, boxed)
340340
else transformExplicitType(tree.tpe, boxed))
341341

342-
private def updateInfo(sym: Symbol, tpe: Type)(using Context) =
343-
sym.updateInfoBetween(preRecheckPhase, thisPhase, tpe)
342+
private def updateInfo(sym: Symbol, info: Type)(using Context) =
343+
sym.updateInfoBetween(preRecheckPhase, thisPhase, info)
344344

345345
def traverse(tree: Tree)(using Context): Unit =
346346
tree match

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
202202
}.close
203203
case tp @ EventuallyCapturingType(parent, refs) =>
204204
def box =
205-
Str("box ") provided tp.isBoxed && ctx.settings.YccDebug.value
205+
Str("box ") provided tp.isBoxed //&& ctx.settings.YccDebug.value
206206
if printDebug && !refs.isConst then
207207
changePrec(GlobalPrec)(box ~ s"$refs " ~ toText(parent))
208208
else if ctx.settings.YccDebug.value then

tests/neg-custom-args/captures/capt1.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@
4141
31 | val z2 = h[() -> Cap](() => x)(() => C()) // error
4242
| ^^^^^^^
4343
| Found: {x} () -> Cap
44-
| Required: () -> Cap
44+
| Required: () -> box {*} C
4545
|
4646
| longer explanation available when compiling with `-explain`

tests/neg-custom-args/captures/real-try.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
-- Error: tests/neg-custom-args/captures/real-try.scala:30:4 -----------------------------------------------------------
2020
30 | b.x // error
2121
| ^^^
22-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
22+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
2323
| This usually means that a capability persists longer than its allowed lifetime.

tests/neg-custom-args/captures/try.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
23 | (x: CanThrow[Exception]) => x
44
24 | }{ // error
55
| ^
6-
| The expression's type {*} CT[Exception] is not allowed to capture the root capability `*`.
6+
| The expression's type box {*} CT[Exception] is not allowed to capture the root capability `*`.
77
| This usually means that a capability persists longer than its allowed lifetime.
88
25 | (ex: Exception) => ???
99
26 | }
@@ -24,7 +24,7 @@
2424
38 | 22
2525
39 | } { // error
2626
| ^
27-
| The expression's type {*} () -> Int is not allowed to capture the root capability `*`.
27+
| The expression's type box {*} () -> Int is not allowed to capture the root capability `*`.
2828
| This usually means that a capability persists longer than its allowed lifetime.
2929
40 | (ex: Exception) => () => 22
3030
41 | }
@@ -36,7 +36,7 @@
3636
50 | 22
3737
51 |} { // error
3838
| ^
39-
| The expression's type {*} () -> Int is not allowed to capture the root capability `*`.
39+
| The expression's type box {*} () -> Int is not allowed to capture the root capability `*`.
4040
| This usually means that a capability persists longer than its allowed lifetime.
4141
52 | (ex: Exception) => () => 22
4242
53 |}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:23:27 ------------------------------------------------------
22
23 | val later = usingLogFile { f => () => f.write(0) } // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
4+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
55
| This usually means that a capability persists longer than its allowed lifetime.
66
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:29:9 -------------------------------------------------------
77
29 | later2.x() // error
88
| ^^^^^^^^
9-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
9+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
1010
| This usually means that a capability persists longer than its allowed lifetime.
1111
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:31:6 -------------------------------------------------------
1212
31 | var later3: () => Unit = () => () // error
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14-
| The mutable variable's type {*} () -> Unit is not allowed to capture the root capability `*`.
14+
| The mutable variable's type box {*} () -> Unit is not allowed to capture the root capability `*`.
1515
| This usually means that a capability persists longer than its allowed lifetime.
1616
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:37:9 -------------------------------------------------------
1717
37 | later4.x() // error
1818
| ^^^^^^^^
19-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
19+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
2020
| This usually means that a capability persists longer than its allowed lifetime.
2121
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:47:27 ------------------------------------------------------
2222
47 | val later = usingLogFile { f => () => f.write(0) } // error
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
24+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
2525
| This usually means that a capability persists longer than its allowed lifetime.
2626
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:62:25 ------------------------------------------------------
2727
62 | val later = usingFile("out", f => (y: Int) => xs.foreach(x => f.write(x + y))) // error
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29-
| The expression's type {*} (x$0: Int) -> Unit is not allowed to capture the root capability `*`.
30-
| This usually means that a capability persists longer than its allowed lifetime.
29+
| The expression's type box {*} (x$0: Int) -> Unit is not allowed to capture the root capability `*`.
30+
| This usually means that a capability persists longer than its allowed lifetime.
3131
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:71:25 ------------------------------------------------------
3232
71 | val later = usingFile("logfile", usingLogger(_, l => () => l.log("test"))) // error
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34-
| The expression's type {*} () -> Unit is not allowed to capture the root capability `*`.
34+
| The expression's type box {*} () -> Unit is not allowed to capture the root capability `*`.
3535
| This usually means that a capability persists longer than its allowed lifetime.

tests/neg-custom-args/captures/vars.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
-- Error: tests/neg-custom-args/captures/vars.scala:13:6 ---------------------------------------------------------------
99
13 | var a: String => String = f // error
1010
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
11-
| The mutable variable's type {*} String -> String is not allowed to capture the root capability `*`.
11+
| The mutable variable's type box {*} String -> String is not allowed to capture the root capability `*`.
1212
| This usually means that a capability persists longer than its allowed lifetime.
1313
-- Error: tests/neg-custom-args/captures/vars.scala:15:4 ---------------------------------------------------------------
1414
15 | b.head // error
1515
| ^^^^^^
16-
| The expression's type {*} String -> String is not allowed to capture the root capability `*`.
16+
| The expression's type box {*} String -> String is not allowed to capture the root capability `*`.
1717
| This usually means that a capability persists longer than its allowed lifetime.
1818
-- Error: tests/neg-custom-args/captures/vars.scala:30:8 ---------------------------------------------------------------
1919
30 | local { cap3 => // error
2020
| ^
21-
| The expression's type {*} (x$0: ? String) -> ? String is not allowed to capture the root capability `*`.
21+
| The expression's type box {*} (x$0: ? String) -> ? String is not allowed to capture the root capability `*`.
2222
| This usually means that a capability persists longer than its allowed lifetime.
2323
31 | def g(x: String): String = if cap3 == cap3 then "" else "a"
2424
32 | g

0 commit comments

Comments
 (0)