Skip to content

Commit 7bb666c

Browse files
committed
Drop Mode.PrintShowExceptions && add Mode docs
Free up Mode bit 18, by reusing -Yshow-print-errors.
1 parent dde69ce commit 7bb666c

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ object Decorators {
279279
catch
280280
case ex: CyclicReference => "... (caught cyclic reference) ..."
281281
case NonFatal(ex)
282-
if !ctx.mode.is(Mode.PrintShowExceptions) && !ctx.settings.YshowPrintErrors.value =>
282+
if !ctx.settings.YshowPrintErrors.value =>
283283
s"... (cannot display due to ${ex.className} ${ex.getMessage}) ..."
284284
case _ => String.valueOf(x).nn
285285

compiler/src/dotty/tools/dotc/core/Mode.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
package dotty.tools.dotc.core
22

3-
/** A collection of mode bits that are part of a context */
3+
/** A collection of mode bits that are part of a context.
4+
*
5+
* What's the difference between a boolean setting and a Mode?
6+
* A setting is usually valid for the entire compilation run, whereas a mode is context specific.
7+
* Changing a setting in a context creates a new SettingsState in that context, which is a relatively big object.
8+
* By comparison, a mode is just an Int.
9+
* But, Mode bits are a scarce resource, so for low priority situations, just reset the state with a setting.
10+
* Also, a setting is externally settable, while a mode isn't.
11+
*/
412
case class Mode(val bits: Int) extends AnyVal {
513
import Mode._
614
def | (that: Mode): Mode = Mode(bits | that.bits)
@@ -112,9 +120,6 @@ object Mode {
112120
/** Read original positions when unpickling from TASTY */
113121
val ReadPositions: Mode = newMode(17, "ReadPositions")
114122

115-
/** Don't suppress exceptions thrown during show */
116-
val PrintShowExceptions: Mode = newMode(18, "PrintShowExceptions")
117-
118123
val PatternOrTypeBits: Mode = Pattern | Type
119124

120125
/** We are elaborating the fully qualified name of a package clause.

compiler/src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ class Pickler extends Phase {
153153
else
154154
super.runOn(units)
155155
if ctx.settings.YtestPickler.value then
156-
val ctx2 = ctx.fresh.setSetting(ctx.settings.YreadComments, true)
156+
val ctx2 = ctx.fresh
157+
.setSetting(ctx.settings.YreadComments, true)
158+
.setSetting(ctx.settings.YshowPrintErrors, true)
157159
testUnpickler(
158160
using ctx2
159-
.setPeriod(Period(ctx.runId + 1, ctx.base.typerPhase.id))
160-
.setReporter(new ThrowingReporter(ctx.reporter))
161-
.addMode(Mode.ReadPositions)
162-
.addMode(Mode.PrintShowExceptions))
161+
.setPeriod(Period(ctx.runId + 1, ctx.base.typerPhase.id))
162+
.setReporter(new ThrowingReporter(ctx.reporter))
163+
.addMode(Mode.ReadPositions)
164+
)
163165
result
164166
}
165167

0 commit comments

Comments
 (0)