Skip to content

Reorder unpickled type params if necessary #923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down