@@ -136,46 +136,16 @@ object report:
136
136
def formatExplain (pairs : List [(String , Any )]) = pairs.map((k, v) => f " $k%20s: $v" ).mkString(" \n " )
137
137
138
138
val settings = ctx.settings.userSetSettings(ctx.settingsState).sortBy(_.name)
139
- val tree = ctx.tree
140
- val sym = tree.symbol
141
- val pos = tree.sourcePos
142
- val path = pos.source.path
143
- val site = ctx.outersIterator.map(_.owner).filter(sym => ! sym.exists || sym.isClass || sym.is(Method )).next()
144
-
145
- import untpd .*
146
- extension (tree : Tree ) def summaryString : String = tree match
147
- case Literal (const) => s " Literal( $const) "
148
- case Ident (name) => s " Ident( ${name.decode}) "
149
- case Select (qual, name) => s " Select( ${qual.summaryString}, ${name.decode}) "
150
- case tree : NameTree => (if tree.isType then " type " else " " ) + tree.name.decode
151
- case tree => s " ${tree.className}${if tree.symbol.exists then s " ( ${tree.symbol}) " else " " }"
139
+ def showSetting (s : Setting [? ]): String = if s.value == " " then s " ${s.name} \"\" " else s " ${s.name} ${s.value}"
152
140
153
141
val info1 = formatExplain(List (
154
142
" while compiling" -> ctx.compilationUnit,
155
143
" during phase" -> ctx.phase.megaPhase,
156
144
" mode" -> ctx.mode,
157
145
" library version" -> scala.util.Properties .versionString,
158
146
" compiler version" -> dotty.tools.dotc.config.Properties .versionString,
159
- " settings" -> settings.map(s => if s.value == " " then s " ${s.name} \"\" " else s " ${s.name} ${s.value} " ).mkString(" " ),
147
+ " settings" -> settings.map(showSetting ).mkString(" " ),
160
148
))
161
- val symbolInfos = if sym eq NoSymbol then List (" symbol" -> sym) else List (
162
- " symbol" -> sym.showLocated,
163
- " symbol definition" -> s " ${sym.showDcl} (a ${sym.className}) " ,
164
- " symbol package" -> sym.enclosingPackageClass.fullName,
165
- " symbol owners" -> sym.showExtendedLocation,
166
- )
167
- val info2 = formatExplain(List (
168
- " tree" -> tree.summaryString,
169
- " tree position" -> (if pos.exists then s " $path: ${pos.line + 1 }: ${pos.column}" else s " $path:<unknown> " ),
170
- " tree type" -> tree.typeOpt.show,
171
- ) ::: symbolInfos ::: List (
172
- " call site" -> s " ${site.showLocated} in ${site.enclosingPackageClass}"
173
- ))
174
- val context_s = try
175
- s """ == Source file context for tree position ==
176
- |
177
- | ${messageRendering.messageAndPos(Diagnostic .Error (" " , pos))}""" .stripMargin
178
- catch case _ : Exception => " <Cannot read source file>"
179
149
s """
180
150
| $errorMessage
181
151
|
@@ -184,9 +154,6 @@ object report:
184
154
| https://github.com/lampepfl/dotty/issues/new/choose
185
155
|
186
156
| $info1
187
- |
188
- | $info2
189
- |
190
- | $context_s""" .stripMargin
157
+ | """ .stripMargin
191
158
} catch case _ : Throwable => errorMessage // don't introduce new errors trying to report errors, so swallow exceptions
192
159
end report
0 commit comments