aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-05 16:58:14 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-05 16:59:05 +0100
commitc7e71b81f0bf4ccf1f2d442e0425fe6f0dfe2c99 (patch)
tree4341967bbf5ef57494dadea1c72f610274b4afc2 /src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
parent041d42f58eae860f88d6f1ea54305c1a7dca6c42 (diff)
downloaddotty-c7e71b81f0bf4ccf1f2d442e0425fe6f0dfe2c99.tar.gz
dotty-c7e71b81f0bf4ccf1f2d442e0425fe6f0dfe2c99.tar.bz2
dotty-c7e71b81f0bf4ccf1f2d442e0425fe6f0dfe2c99.zip
Surive non-existing sourceModule in Scala2 pickled info.
It seems when unpickling nsc that some module classes come without a source module. Survive this situation rather than crashing. i859.scala is an example. i859 compiles with the patch, but causes a deep subtype when unpickling. Not sure whether scalac does the same.
Diffstat (limited to 'src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index 618e3ceea..abf31a006 100644
--- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -101,10 +101,12 @@ object Scala2Unpickler {
case cinfo => (Nil, cinfo)
}
val ost =
- if ((selfInfo eq NoType) && (denot is ModuleClass))
+ if ((selfInfo eq NoType) && (denot is ModuleClass) && denot.sourceModule.exists)
+ // it seems sometimes the source module does not exist for a module class.
+ // An example is `scala.reflect.internal.Trees.Template$. Without the
+ // `denot.sourceModule.exists` provision i859.scala crashes in the backend.
denot.owner.thisType select denot.sourceModule
else selfInfo
-
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, Nil, decls, ost) // first rough info to avoid CyclicReferences
var parentRefs = ctx.normalizeToClassRefs(parents, cls, decls)
if (parentRefs.isEmpty) parentRefs = defn.ObjectType :: Nil