@@ -180,7 +180,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
180
180
181
181
def annotText (tree : untpd.Tree ): Text = " @" ~ constrText(tree) // DD
182
182
183
- def useSymbol = ctx.isAfterTyper(ctx.phase) && tree.hasType && tree.symbol.exists
183
+ def useSymbol =
184
+ tree.hasType && tree.symbol.exists && ctx.settings.YprintSyms .value
184
185
185
186
def modText (mods : untpd.Modifiers , kw : String ): Text = { // DD
186
187
val suppressKw = if (ownerIsClass) mods is ParamAndLocal else mods is Param
@@ -209,6 +210,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
209
210
if (ctx.settings.uniqid.value && tree.hasType && tree.symbol.exists) s " # ${tree.symbol.id}" else " "
210
211
}
211
212
213
+ def nameIdText (tree : untpd.NameTree ): Text =
214
+ toText(tree.name) ~ idText(tree)
215
+
212
216
import untpd ._
213
217
214
218
var txt : Text = tree match {
@@ -219,8 +223,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
219
223
case tp : NamedType if name != nme.WILDCARD => toTextPrefix(tp.prefix) ~ selectionString(tp)
220
224
case _ => toText(name)
221
225
}
222
- case Select (qual, name) =>
223
- toTextLocal(qual) ~ (" ." ~ toText(name ) provided name != nme.CONSTRUCTOR )
226
+ case tree @ Select (qual, name) =>
227
+ toTextLocal(qual) ~ (" ." ~ nameIdText(tree ) provided name != nme.CONSTRUCTOR )
224
228
case This (name) =>
225
229
optDotPrefix(name) ~ " this" ~ idText(tree)
226
230
case Super (This (name), mix) =>
@@ -297,15 +301,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
297
301
toTextLocal(extractor) ~
298
302
" (" ~ toTextGlobal(patterns, " , " ) ~ " )" ~
299
303
(" (" ~ toTextGlobal(implicits, " , " ) ~ " )" provided implicits.nonEmpty)
300
- case ValDef (mods, name, tpt, rhs) =>
304
+ case tree @ ValDef (mods, name, tpt, rhs) =>
301
305
dclTextOr {
302
- modText(mods, if (mods is Mutable ) " var" else " val" ) ~~ toText(name ) ~
306
+ modText(mods, if (mods is Mutable ) " var" else " val" ) ~~ nameIdText(tree ) ~
303
307
optAscription(tpt)
304
308
} ~ optText(rhs)(" = " ~ _)
305
- case DefDef (mods, name, tparams, vparamss, tpt, rhs) =>
309
+ case tree @ DefDef (mods, name, tparams, vparamss, tpt, rhs) =>
306
310
atOwner(tree) {
307
311
dclTextOr {
308
- val first = modText(mods, " def" ) ~~ toText(name ) ~ tparamsText(tparams)
312
+ val first = modText(mods, " def" ) ~~ nameIdText(tree ) ~ tparamsText(tparams)
309
313
addVparamssText(first, vparamss) ~ optAscription(tpt)
310
314
} ~ optText(rhs)(" = " ~ _)
311
315
}
@@ -314,11 +318,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
314
318
def typeDefText (rhsText : Text ) =
315
319
dclTextOr {
316
320
val rhsText1 = if (tree.hasType) toText(tree.symbol.info) else rhsText
317
- modText(mods, " type" ) ~~ toText(name ) ~ tparamsText(tree.tparams) ~ rhsText1
321
+ modText(mods, " type" ) ~~ nameIdText(tree ) ~ tparamsText(tree.tparams) ~ rhsText1
318
322
}
319
323
rhs match {
320
324
case impl : Template =>
321
- modText(mods, if (mods is Trait ) " trait" else " class" ) ~~ toText(name) ~~ idText (tree) ~ toText(impl) ~
325
+ modText(mods, if (mods is Trait ) " trait" else " class" ) ~~ nameIdText (tree) ~ toText(impl) ~
322
326
(if (tree.hasType && ctx.settings.verbose.value) s " [decls = ${tree.symbol.info.decls}] " else " " )
323
327
case rhs : TypeBoundsTree =>
324
328
typeDefText(toText(rhs))
@@ -367,9 +371,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
367
371
" <empty>"
368
372
case TypedSplice (t) =>
369
373
toText(t)
370
- case ModuleDef (mods, name, impl) =>
374
+ case tree @ ModuleDef (mods, name, impl) =>
371
375
atOwner(tree) {
372
- modText(mods, " object" ) ~~ toText(name ) ~ toText(impl)
376
+ modText(mods, " object" ) ~~ nameIdText(tree ) ~ toText(impl)
373
377
}
374
378
case SymbolLit (str) =>
375
379
" '" + str
0 commit comments