aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-15 22:01:42 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-15 22:01:42 +0200
commitc190626eb0a7c6a314429bb4f3c498da989395fc (patch)
treeb33b87a0d2cdc5b8d75be698143e1a7e759460db /src/dotty/tools/dotc/printing
parent658fc7f7070e8f13abd0391ff4e6045ac34e2891 (diff)
downloaddotty-c190626eb0a7c6a314429bb4f3c498da989395fc.tar.gz
dotty-c190626eb0a7c6a314429bb4f3c498da989395fc.tar.bz2
dotty-c190626eb0a7c6a314429bb4f3c498da989395fc.zip
Removed ClassDef as a Tree node class.
ClassDefs are now TypeDefs that have a Template as rhs.
Diffstat (limited to 'src/dotty/tools/dotc/printing')
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index 9df2c053f..dc3956fca 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -25,8 +25,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
finally { currentOwner = saved }
}
- private def ownerIsClass =
- currentOwner.isInstanceOf[ClassDef[_]] || currentOwner.isInstanceOf[untpd.ModuleDef]
+ private def ownerIsClass = currentOwner match {
+ case owner: TypeDef[_] => owner.isClassDef
+ case owner: untpd.ModuleDef => true
+ case _ => false
+ }
override def nameString(name: Name): String = name.decode.toString
@@ -216,11 +219,16 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
}
case tree @ TypeDef(mods, name, rhs) =>
atOwner(tree) {
- val rhsText = rhs match {
- case TypeBoundsTree(_, _) => toText(rhs)
- case _ => optText(rhs)(" = " ~ _)
+ def typeDefText(rhsText: Text) =
+ modText(mods, "type") ~~ toText(name) ~ tparamsText(tree.tparams) ~ rhsText
+ rhs match {
+ case impl: Template =>
+ modText(mods, if (mods is Trait) "trait" else "class") ~~ toText(name) ~ toText(impl)
+ case rhs: TypeBoundsTree =>
+ typeDefText(toText(rhs))
+ case _ =>
+ typeDefText(optText(rhs)(" = " ~ _))
}
- modText(mods, "type") ~~ toText(name) ~ tparamsText(tree.tparams) ~ rhsText
}
case Template(DefDef(mods, _, tparams, vparamss, _, _), parents, self, stats) =>
val tparamsTxt = tparamsText(tparams)
@@ -238,10 +246,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
} provided !self.isEmpty
val bodyText = "{" ~~ selfText ~~ toTextGlobal(stats, "\n") ~ "}"
prefix ~~ (" extends" provided ownerIsClass) ~~ parentsText ~~ bodyText
- case ClassDef(mods, name, impl) =>
- atOwner(tree) {
- modText(mods, if (mods is Trait) "trait" else "class") ~~ toText(name) ~ toText(impl)
- }
case Import(expr, selectors) =>
def selectorText(sel: Tree): Text = sel match {
case Pair(l, r) => toTextGlobal(l) ~ " => " ~ toTextGlobal(r)