Skip to content

Commit b2edfa6

Browse files
dwijnandKordyjan
authored andcommitted
Drop Mode.PrintShowExceptions && add Mode docs
Free up Mode bit 18, by reusing -Yshow-print-errors. [Cherry-picked 7bb666c]
1 parent 53e9ce8 commit b2edfa6

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)
@@ -98,9 +106,6 @@ object Mode {
98106
/** Read original positions when unpickling from TASTY */
99107
val ReadPositions: Mode = newMode(17, "ReadPositions")
100108

101-
/** Don't suppress exceptions thrown during show */
102-
val PrintShowExceptions: Mode = newMode(18, "PrintShowExceptions")
103-
104109
val PatternOrTypeBits: Mode = Pattern | Type
105110

106111
/** 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)