diff --git a/compiler/src/dotty/tools/dotc/report.scala b/compiler/src/dotty/tools/dotc/report.scala index 11ab38b3f5ae..247e67b5be36 100644 --- a/compiler/src/dotty/tools/dotc/report.scala +++ b/compiler/src/dotty/tools/dotc/report.scala @@ -136,19 +136,7 @@ object report: def formatExplain(pairs: List[(String, Any)]) = pairs.map((k, v) => f"$k%20s: $v").mkString("\n") val settings = ctx.settings.userSetSettings(ctx.settingsState).sortBy(_.name) - val tree = ctx.tree - val sym = tree.symbol - val pos = tree.sourcePos - val path = pos.source.path - val site = ctx.outersIterator.map(_.owner).filter(sym => !sym.exists || sym.isClass || sym.is(Method)).next() - - import untpd.* - extension (tree: Tree) def summaryString: String = tree match - case Literal(const) => s"Literal($const)" - case Ident(name) => s"Ident(${name.decode})" - case Select(qual, name) => s"Select(${qual.summaryString}, ${name.decode})" - case tree: NameTree => (if tree.isType then "type " else "") + tree.name.decode - case tree => s"${tree.className}${if tree.symbol.exists then s"(${tree.symbol})" else ""}" + def showSetting(s: Setting[?]): String = if s.value == "" then s"${s.name} \"\"" else s"${s.name} ${s.value}" val info1 = formatExplain(List( "while compiling" -> ctx.compilationUnit, @@ -156,26 +144,8 @@ object report: "mode" -> ctx.mode, "library version" -> scala.util.Properties.versionString, "compiler version" -> dotty.tools.dotc.config.Properties.versionString, - "settings" -> settings.map(s => if s.value == "" then s"${s.name} \"\"" else s"${s.name} ${s.value}").mkString(" "), + "settings" -> settings.map(showSetting).mkString(" "), )) - val symbolInfos = if sym eq NoSymbol then List("symbol" -> sym) else List( - "symbol" -> sym.showLocated, - "symbol definition" -> s"${sym.showDcl} (a ${sym.className})", - "symbol package" -> sym.enclosingPackageClass.fullName, - "symbol owners" -> sym.showExtendedLocation, - ) - val info2 = formatExplain(List( - "tree" -> tree.summaryString, - "tree position" -> (if pos.exists then s"$path:${pos.line + 1}:${pos.column}" else s"$path:"), - "tree type" -> tree.typeOpt.show, - ) ::: symbolInfos ::: List( - "call site" -> s"${site.showLocated} in ${site.enclosingPackageClass}" - )) - val context_s = try - s""" == Source file context for tree position == - | - |${messageRendering.messageAndPos(Diagnostic.Error("", pos))}""".stripMargin - catch case _: Exception => "" s""" | $errorMessage | @@ -184,9 +154,6 @@ object report: | https://github.com/lampepfl/dotty/issues/new/choose | |$info1 - | - |$info2 - | - |$context_s""".stripMargin + |""".stripMargin } catch case _: Throwable => errorMessage // don't introduce new errors trying to report errors, so swallow exceptions end report