aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/RefinedPrinter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-13 21:30:54 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-13 21:30:54 +0200
commita3f6a1df1bd623ee913e41f739b3f13ac9638d14 (patch)
treee93a442c6adc8da3307e03923e90a7edcda41e09 /src/dotty/tools/dotc/printing/RefinedPrinter.scala
parenta5f576f147d5e9272629992936ed1e45c0a05020 (diff)
downloaddotty-a3f6a1df1bd623ee913e41f739b3f13ac9638d14.tar.gz
dotty-a3f6a1df1bd623ee913e41f739b3f13ac9638d14.tar.bz2
dotty-a3f6a1df1bd623ee913e41f739b3f13ac9638d14.zip
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).
Diffstat (limited to 'src/dotty/tools/dotc/printing/RefinedPrinter.scala')
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala10
1 files changed, 6 insertions, 4 deletions
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)
}