From 01db9a68e5e68f08c8236c23c905009789d51587 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 14 Dec 2013 17:32:16 +0100 Subject: Fixed several deep problems in handling of types and symbols. 1. We forgot to mark declaration symbols Deferred. 2. Types with NoPrefix and the same name got identified. Fixed by adding a new category WithNoPrefix to named types, and changing the way named types get generated. 3. Self types lacked parameters. (Question: Do we need to also track type members?) 4. Printers caused cyclic reference errors. Now some print operations are more careful with forcing. 5. Namedparts accumulator has to be more careful with ThisTypes. Because self types now contain parameters, which might lead back to this, we only add the class name (or the source module, if it's a module class). 6. toBounds in TypeApplications needs to use Co/Contra aliases for expanded name parameters, not just local ones. --- src/dotty/tools/dotc/printing/PlainPrinter.scala | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/printing/PlainPrinter.scala') diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index 11a984ad3..791380852 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -219,6 +219,14 @@ class PlainPrinter(_ctx: Context) extends Printer { protected def isEmptyPrefix(sym: Symbol) = sym.isEffectiveRoot || sym.isAnonymousClass || sym.name.isReplWrapperName + /** String representation of a definition's type following its name, + * if symbol is completed, "?" otherwise. + */ + protected def toTextRHS(optType: Option[Type]): Text = optType match { + case Some(tp) => toTextRHS(tp) + case None => "?" + } + /** String representation of a definition's type following its name */ protected def toTextRHS(tp: Type): Text = controlled { tp match { @@ -295,14 +303,14 @@ class PlainPrinter(_ctx: Context) extends Printer { else if (flags is Mutable) "var" else if (flags is Package) "package" else if (flags is Module) "object" - else if (sym.isSourceMethod) "def" + else if (sym.isCompleted && sym.isSourceMethod) "def" else if (sym.isTerm && (!(flags is Param))) "val" else "" } /** String representation of symbol's flags */ protected def toTextFlags(sym: Symbol): Text = - Text(sym.flags.flagStrings map stringToText, " ") + Text(sym.flagsUNSAFE.flagStrings map stringToText, " ") /** String representation of symbol's variance or "" if not applicable */ protected def varianceString(sym: Symbol): String = sym.variance match { @@ -313,7 +321,7 @@ class PlainPrinter(_ctx: Context) extends Printer { def dclText(sym: Symbol): Text = (toTextFlags(sym) ~~ keyString(sym) ~~ - (varianceString(sym) ~ nameString(sym)) ~ toTextRHS(sym.info)).close + (varianceString(sym) ~ nameString(sym)) ~ toTextRHS(sym.unforcedInfo)).close def toText(sym: Symbol): Text = (kindString(sym) ~~ { -- cgit v1.2.3