diff options
author | odersky <odersky@gmail.com> | 2015-04-23 20:56:07 +0200 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-04-23 20:56:07 +0200 |
commit | 4efcfa6a17eb04021cdeec85283bed786e2d15be (patch) | |
tree | 933813bba8432087af2c30ab464f7679e78e6ecf | |
parent | e47ecb138efae9a1fd80034b6925a2a517931cf3 (diff) | |
parent | 72d91a32888d6e35cb7ee33437329c8c751f2af1 (diff) | |
download | dotty-4efcfa6a17eb04021cdeec85283bed786e2d15be.tar.gz dotty-4efcfa6a17eb04021cdeec85283bed786e2d15be.tar.bz2 dotty-4efcfa6a17eb04021cdeec85283bed786e2d15be.zip |
Merge pull request #475 from dotty-staging/fix/pickle-homogenization
Fix/pickle homogenization
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TreePickler.scala | 20 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/PlainPrinter.scala | 19 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 5 |
3 files changed, 32 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreePickler.scala b/src/dotty/tools/dotc/core/pickling/TreePickler.scala index 53dd34094..e463b4447 100644 --- a/src/dotty/tools/dotc/core/pickling/TreePickler.scala +++ b/src/dotty/tools/dotc/core/pickling/TreePickler.scala @@ -171,8 +171,11 @@ class TreePickler(pickler: TastyPickler) { else pickleRef() } case tpe: TermRefWithSignature => - writeByte(TERMREF) - pickleNameAndSig(tpe.name, tpe.signature); pickleType(tpe.prefix) + if (tpe.symbol.is(Flags.Package)) picklePackageRef(tpe.symbol) + else { + writeByte(TERMREF) + pickleNameAndSig(tpe.name, tpe.signature); pickleType(tpe.prefix) + } case tpe: NamedType => if (tpe.name == tpnme.Apply && tpe.prefix.argInfos.nonEmpty && tpe.prefix.isInstantiatedLambda) // instantiated lambdas are pickled as APPLIEDTYPE; #Apply will @@ -187,8 +190,12 @@ class TreePickler(pickler: TastyPickler) { pickleName(tpe.name); pickleType(tpe.prefix) } case tpe: ThisType => - writeByte(THIS) - pickleType(tpe.tref) + if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot) + picklePackageRef(tpe.cls) + else { + writeByte(THIS) + pickleType(tpe.tref) + } case tpe: SuperType => writeByte(SUPERtype) withLength { pickleType(tpe.thistpe); pickleType(tpe.supertpe)} @@ -253,6 +260,11 @@ class TreePickler(pickler: TastyPickler) { println(i"error while pickling type $tpe") throw ex } + + def picklePackageRef(pkg: Symbol): Unit = { + writeByte(TERMREFpkg) + pickleName(qualifiedName(pkg)) + } def pickleMethodic(result: Type, names: List[Name], types: List[Type]) = withLength { diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index 0a7edd2aa..f3ffd6f6f 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -40,9 +40,14 @@ class PlainPrinter(_ctx: Context) extends Printer { def homogenize(tp: Type): Type = if (homogenizedView) tp match { - case tp: TypeVar if tp.isInstantiated => homogenize(tp.instanceOpt) - case AndType(tp1, tp2) => homogenize(tp1) & homogenize(tp2) - case OrType(tp1, tp2) => homogenize(tp1) | homogenize(tp2) + case tp: ThisType if tp.cls.is(Package) && !tp.cls.isEffectiveRoot => + ctx.requiredPackage(tp.cls.fullName).termRef + case tp: TypeVar if tp.isInstantiated => + homogenize(tp.instanceOpt) + case AndType(tp1, tp2) => + homogenize(tp1) & homogenize(tp2) + case OrType(tp1, tp2) => + homogenize(tp1) | homogenize(tp2) case _ => val tp1 = tp.simplifyApply if (tp1 eq tp) tp else homogenize(tp1) @@ -230,10 +235,10 @@ class PlainPrinter(_ctx: Context) extends Printer { /** The string representation of this type used as a prefix */ protected def toTextPrefix(tp: Type): Text = controlled { - tp match { + homogenize(tp) match { case NoPrefix => "" case tp: SingletonType => toTextRef(tp) ~ "." - case _ => trimPrefix(toTextLocal(tp)) ~ "#" + case tp => trimPrefix(toTextLocal(tp)) ~ "#" } } @@ -253,7 +258,7 @@ class PlainPrinter(_ctx: Context) extends Printer { /** String representation of a definition's type following its name */ protected def toTextRHS(tp: Type): Text = controlled { - tp match { + homogenize(tp) match { case tp @ TypeBounds(lo, hi) => if (lo eq hi) { val eql = @@ -280,7 +285,7 @@ class PlainPrinter(_ctx: Context) extends Printer { else dclsText(trueDecls) tparamsText ~ " extends " ~ toTextParents(tp.parents) ~ "{" ~ selfText ~ declsText ~ "} at " ~ preText - case _ => + case tp => ": " ~ toTextGlobal(tp) } } diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 423c62044..67bd65bc7 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -63,7 +63,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } override def toTextPrefix(tp: Type): Text = controlled { - def isOmittable(sym: Symbol) = isOmittablePrefix(sym) && !ctx.settings.verbose.value + def isOmittable(sym: Symbol) = + if (ctx.settings.verbose.value) false + else if (homogenizedView) isEmptyPrefix(sym) // drop <root> and anonymous classes, but not scala, Predef. + else isOmittablePrefix(sym) tp match { case tp: ThisType => if (isOmittable(tp.cls)) return "" |