Skip to content

Commit 0ef14c3

Browse files
committed
Tweak printing in MessagePrinter
Fall back to previous scheme if there is no recording in Seen. That way, we see what we expect when turning on Ycc-verbose and other printing options.
1 parent b6a77e6 commit 0ef14c3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/reporting/Message.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ object Message:
7676
/** If false, stop all recordings */
7777
private var disambi = disambiguate
7878

79+
def isActive = disambi != Disambiguation.None
80+
7981
/** Clear all entries and stop further entries to be added */
8082
def disable() =
8183
seen.clear()
@@ -266,20 +268,20 @@ object Message:
266268
case _ => super.toTextRef(tp)
267269

268270
override def toTextCaptureRef(tp: Type): Text = tp match
269-
case tp: CaptureRef if tp.isRootCapability && !tp.isReadOnly =>
271+
case tp: CaptureRef if tp.isRootCapability && !tp.isReadOnly && seen.isActive =>
270272
seen.record("cap", isType = false, tp)
271273
case _ => super.toTextCaptureRef(tp)
272274

273275
override def toTextCapturing(parent: Type, refs: GeneralCaptureSet, boxText: Text) = refs match
274276
case refs: CaptureSet
275-
if isUniversalCaptureSet(refs) && !defn.isFunctionType(parent) && !printDebug =>
277+
if isUniversalCaptureSet(refs) && !defn.isFunctionType(parent) && !printDebug && seen.isActive =>
276278
boxText ~ toTextLocal(parent) ~ seen.record("^", isType = true, refs.elems.nth(0))
277279
case _ =>
278280
super.toTextCapturing(parent, refs, boxText)
279281

280282
override def funMiddleText(isContextual: Boolean, isPure: Boolean, refs: GeneralCaptureSet | Null): Text =
281283
refs match
282-
case refs: CaptureSet if isUniversalCaptureSet(refs) =>
284+
case refs: CaptureSet if isUniversalCaptureSet(refs) && seen.isActive =>
283285
seen.record(arrow(isContextual, isPure = false), isType = true, refs.elems.nth(0))
284286
case _ =>
285287
super.funMiddleText(isContextual, isPure, refs)

0 commit comments

Comments
 (0)