Skip to content

Commit 20ff611

Browse files
committed
Improve context printing
1 parent ba58d4d commit 20ff611

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,17 @@ object Contexts {
538538
case _ => new Typer
539539
}
540540

541-
override def toString: String = {
542-
def iinfo(using Context) = if (ctx.importInfo == null) "" else i"${ctx.importInfo.selectors}%, %"
543-
"Context(\n" +
544-
(outersIterator.map(ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = ${iinfo(using ctx)}").mkString("\n"))
545-
}
541+
override def toString: String =
542+
def iinfo(using Context) =
543+
if (ctx.importInfo == null) "" else i"${ctx.importInfo.selectors}%, %"
544+
def cinfo(using Context) =
545+
val core = s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = ${iinfo(using ctx)}"
546+
if (ctx ne NoContext) && (ctx.implicits ne ctx.outer.implicits) then
547+
s"$core, implicits = ${ctx.implicits}"
548+
else
549+
core
550+
s"""Context(
551+
|${outersIterator.map(ctx => cinfo(using ctx)).mkString("\n\n")})""".stripMargin
546552

547553
def settings: ScalaSettings = base.settings
548554
def definitions: Definitions = base.definitions

0 commit comments

Comments
 (0)