From a3f6a1df1bd623ee913e41f739b3f13ac9638d14 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 13 Jun 2013 21:30:54 +0200 Subject: Dropping type parameters from typed TypeDefs. Typed TypeDefs no longer carry tparams. Untyped ones still do, but there is a special PolyTypeDef node for them in untpd. Also, fixed flatten and DeSugarTest to deal with new tree desugarings which are not idempotent (e.g. desugar.classDef, or desugar.valDef). --- src/dotty/tools/dotc/printing/RefinedPrinter.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/printing/RefinedPrinter.scala') diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 23482b773..9df2c053f 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -19,7 +19,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { private var currentOwner: Tree[_ >: Untyped] = emptyTree() def atOwner(owner: Tree[_ >: Untyped])(op: => Text): Text = { - val saved = owner + val saved = currentOwner currentOwner = owner try op finally { currentOwner = saved } @@ -96,7 +96,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { def optAscription(tpt: Tree[T]) = optText(tpt)(": " ~ _) - def tparamsText(params: List[Tree[T]]): Text = + def tparamsText[T >: Untyped](params: List[Tree[T]]): Text = "[" ~ toText(params, ", ") ~ "]" provided params.nonEmpty def addVparamssText(txt: Text, vparamss: List[List[ValDef[T]]]): Text = @@ -214,13 +214,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { val first = modText(mods, "def") ~~ toText(name) ~ tparamsText(tparams) addVparamssText(first, vparamss) ~ optAscription(tpt) ~ optText(rhs)(" = " ~ _) } - case TypeDef(mods, name, tparams, rhs) => + case tree @ TypeDef(mods, name, rhs) => atOwner(tree) { val rhsText = rhs match { case TypeBoundsTree(_, _) => toText(rhs) case _ => optText(rhs)(" = " ~ _) } - modText(mods, "type") ~~ toText(name) ~ tparamsText(tparams) ~ rhsText + modText(mods, "type") ~~ toText(name) ~ tparamsText(tree.tparams) ~ rhsText } case Template(DefDef(mods, _, tparams, vparamss, _, _), parents, self, stats) => val tparamsTxt = tparamsText(tparams) @@ -331,6 +331,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case PatDef(mods, pats, tpt, rhs) => modText(mods, "val") ~~ toText(pats, ", ") ~ optAscription(tpt) ~ optText(rhs)(" = " ~ _) + case Thicket(trees) => + "Thicket {" ~~ toTextGlobal(trees, "\n") ~~ "}" case _ => tree.fallbackToText(this) } -- cgit v1.2.3