aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-06 14:14:36 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-06 14:14:36 +0100
commitad37a192feb2eb0e2ab7415b9ec744310534f39d (patch)
tree2c68208577db0690d37253d164a245e3b60a6d4a /src
parent3e313ac00f51d7d733955d613c554a8807fa7ec2 (diff)
downloaddotty-ad37a192feb2eb0e2ab7415b9ec744310534f39d.tar.gz
dotty-ad37a192feb2eb0e2ab7415b9ec744310534f39d.tar.bz2
dotty-ad37a192feb2eb0e2ab7415b9ec744310534f39d.zip
Refined printing of module names.
Previously printing a simple name always suppressed a module class suffix, which led to sometimes confusing output. Now we are more selective where the suffix is suppressed.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala4
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala9
2 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala
index 5a01964d6..11a984ad3 100644
--- a/src/dotty/tools/dotc/printing/PlainPrinter.scala
+++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala
@@ -170,7 +170,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
if (sym.isRoot || sym == NoSymbol || sym.owner.isEffectiveRoot)
nameString(sym)
else
- fullNameString(sym.effectiveOwner.enclosingClass) + "." + nameString(sym)
+ fullNameString(fullNameOwner(sym)) + "." + nameString(sym)
+
+ protected def fullNameOwner(sym: Symbol): Symbol = sym.effectiveOwner.enclosingClass
protected def objectPrefix = "object "
protected def packagePrefix = "package "
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index 546a3e027..3a83aae63 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -35,15 +35,20 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
override protected def simpleNameString(sym: Symbol): String = {
var name = sym.originalName
- if (sym is ModuleClass) name = name.stripModuleClassSuffix
+ //if (sym is ModuleClass) name = name.stripModuleClassSuffix
name.decode.toString
}
+ override protected def fullNameOwner(sym: Symbol) = {
+ val owner = super.fullNameOwner(sym)
+ if (owner is ModuleClass) owner.sourceModule else owner
+ }
+
override def toTextRef(tp: SingletonType): Text = controlled {
tp match {
case ThisType(cls) =>
if (cls.isAnonymousClass) return "this"
- if (cls is ModuleClass) return fullNameString(cls)
+ if (cls is ModuleClass) return fullNameString(cls.sourceModule)
case _ =>
}
super.toTextRef(tp)