aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/PlainPrinter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-14 17:32:16 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-14 17:32:16 +0100
commit01db9a68e5e68f08c8236c23c905009789d51587 (patch)
tree3e45103b0d36505d6f86f3024e56780e840c156b /src/dotty/tools/dotc/printing/PlainPrinter.scala
parentd65587ae74cfe2dc7601f57e163b7e22bf89582a (diff)
downloaddotty-01db9a68e5e68f08c8236c23c905009789d51587.tar.gz
dotty-01db9a68e5e68f08c8236c23c905009789d51587.tar.bz2
dotty-01db9a68e5e68f08c8236c23c905009789d51587.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/printing/PlainPrinter.scala')
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala14
1 files changed, 11 insertions, 3 deletions
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) ~~ {