From 112e922acdce5d2b1a102be95c211abcb5c0b59d Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 3 Oct 2012 23:31:28 +0200 Subject: upgrades showRaw Fixes the stuff that was irritating, when I was preparing examples for reflection documentation. Has zero impact at stability of scalac, because showRaw isn't used anywhere in the compiler unless invoked explicitly. --- src/reflect/scala/reflect/internal/Printers.scala | 47 ++++++++++++++--------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index fb165ab50f..fd5a7cf88b 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -534,17 +534,16 @@ trait Printers extends api.Printers { self: SymbolTable => depth += 1 args foreach { + case expr: Expr[_] => + print("Expr") + if (printTypes) print(expr.staticType) + print("(") + print(expr.tree) + print(")") case EmptyTree => print("EmptyTree") case emptyValDef: AnyRef if emptyValDef eq self.emptyValDef => print("emptyValDef") - case Literal(Constant(value)) => - def print(s: String) = this.print("Literal(Constant(" + s + "))") - value match { - case s: String => print("\"" + s + "\"") - case null => print(null) - case _ => print(value.toString) - } case tree: Tree => val hasSymbol = tree.hasSymbol && tree.symbol != NoSymbol val isError = hasSymbol && tree.symbol.name.toString == nme.ERROR.toString @@ -568,6 +567,12 @@ trait Printers extends api.Printers { self: SymbolTable => } else { print(name) } + case Constant(s: String) => + print("Constant(\"" + s + "\")") + case Constant(null) => + print("Constant(null)") + case Constant(value) => + print("Constant(" + value + ")") case arg => print(arg) }, @@ -582,14 +587,18 @@ trait Printers extends api.Printers { self: SymbolTable => if (printIds) print("#", sym.id) if (printKinds) print("#", sym.abbreviatedKindString) if (printMirrors) print("%M", footnotes.put[scala.reflect.api.Mirror[_]](mirrorThatLoaded(sym))) - case NoType => - print("NoType") - case NoPrefix => - print("NoPrefix") + case tag: TypeTag[_] => + print("TypeTag(", tag.tpe, ")") + case tag: WeakTypeTag[_] => + print("WeakTypeTag(", tag.tpe, ")") case tpe: Type => val defer = printTypesInFootnotes && !printingFootnotes if (defer) print("[", footnotes.put(tpe), "]") - else printProduct(tpe.asInstanceOf[Product]) + else tpe match { + case NoType => print("NoType") + case NoPrefix => print("NoPrefix") + case _ => printProduct(tpe.asInstanceOf[Product]) + } case mods: Modifiers => print("Modifiers(") if (mods.flags != NoFlags || mods.privateWithin != tpnme.EMPTY || mods.annotations.nonEmpty) print(show(mods.flags)) @@ -598,6 +607,9 @@ trait Printers extends api.Printers { self: SymbolTable => print(")") case name: Name => print(show(name)) + case scope: Scope => + print("Scope") + printIterable(scope.toList) case list: List[_] => print("List") printIterable(list) @@ -645,16 +657,15 @@ trait Printers extends api.Printers { self: SymbolTable => } def show(name: Name): String = name match { + case tpnme.WILDCARD => "tpnme.WILDCARD" case tpnme.EMPTY => "tpnme.EMPTY" - case tpnme.ROOT => "tpnme.ROOT" + case tpnme.ERROR => "tpnme.ERROR" case tpnme.PACKAGE => "tpnme.PACKAGE" - case tpnme.EMPTY_PACKAGE_NAME => "tpnme.EMPTY_PACKAGE_NAME" - case tpnme.WILDCARD => "tpnme.WILDCARD" + case tpnme.WILDCARD_STAR => "tpnme.WILDCARD_STAR" + case nme.WILDCARD => "nme.WILDCARD" case nme.EMPTY => "nme.EMPTY" - case nme.ROOT => "nme.ROOT" + case nme.ERROR => "tpnme.ERROR" case nme.PACKAGE => "nme.PACKAGE" - case nme.EMPTY_PACKAGE_NAME => "nme.EMPTY_PACKAGE_NAME" - case nme.WILDCARD => "nme.WILDCARD" case nme.CONSTRUCTOR => "nme.CONSTRUCTOR" case nme.ROOTPKG => "nme.ROOTPKG" case _ => -- cgit v1.2.3