aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-11-05 09:42:51 +0100
committerodersky <odersky@gmail.com>2015-11-05 09:42:51 +0100
commit0f04188f0b8fa94663741234bbd8cb163b5f42b1 (patch)
tree5b516f38a1904f01b45e6c11f2534efc3e204c11
parent1654ebcafd5635b0c8761ef77beae44c91682e05 (diff)
parentc164deb13f4fcf0a155945e694a59e9c0b3ec119 (diff)
downloaddotty-0f04188f0b8fa94663741234bbd8cb163b5f42b1.tar.gz
dotty-0f04188f0b8fa94663741234bbd8cb163b5f42b1.tar.bz2
dotty-0f04188f0b8fa94663741234bbd8cb163b5f42b1.zip
Merge pull request #923 from dotty-staging/fix-typeparam-order
Reorder unpickled type params if necessary
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala7
-rw-r--r--src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala12
2 files changed, 17 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 126af9259..20d674b86 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -176,7 +176,7 @@ object SymDenotations {
// completions.println(s"completed ${this.debugString}")
}
- protected[dotc] final def info_=(tp: Type) = {
+ protected[dotc] def info_=(tp: Type) = {
/* // DEBUG
def illegal: String = s"illegal type for $this: $tp"
if (this is Module) // make sure module invariants that allow moduleClass and sourceModule to work are kept.
@@ -1177,6 +1177,11 @@ object SymDenotations {
myTypeParams
}
+ override protected[dotc] final def info_=(tp: Type) = {
+ super.info_=(tp)
+ myTypeParams = null // changing the info might change decls, and with it typeParams
+ }
+
/** The denotations of all parents in this class. */
def classParents(implicit ctx: Context): List[TypeRef] = info match {
case classInfo: ClassInfo => classInfo.classParents
diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index cdb733efa..05d4a70fc 100644
--- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -130,8 +130,18 @@ object Scala2Unpickler {
} else {
registerCompanionPair(scalacCompanion, denot.classSymbol)
}
+ val declsTypeParams = denot.typeParams
+ val declsInRightOrder =
+ if (declsTypeParams.corresponds(tparams)(_.name == _.name)) decls
+ else { // create new scope with type parameters in right order
+ val decls1 = newScope
+ for (tparam <- tparams) decls1.enter(decls.lookup(tparam.name))
+ for (sym <- decls) if (!declsTypeParams.contains(sym)) decls1.enter(sym)
+ decls1
+ }
- denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
+ denot.info = ClassInfo(
+ denot.owner.thisType, denot.classSymbol, parentRefs, declsInRightOrder, ost)
}
}