Skip to content

Commit c164deb

Browse files
committed
Reorder unpickled type params if necessary
When compiling Iterator.scala it was observed that the type parameters of BufferedCanBuildFrom appeared inm the wrong order. This fix corrects that, making sure that type parameters appear in the decls scope in the same order as they are given in the epxlicitly unpickled type parameter list.
1 parent d3e5a69 commit c164deb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ object SymDenotations {
176176
// completions.println(s"completed ${this.debugString}")
177177
}
178178

179-
protected[dotc] final def info_=(tp: Type) = {
179+
protected[dotc] def info_=(tp: Type) = {
180180
/* // DEBUG
181181
def illegal: String = s"illegal type for $this: $tp"
182182
if (this is Module) // make sure module invariants that allow moduleClass and sourceModule to work are kept.
@@ -1177,6 +1177,11 @@ object SymDenotations {
11771177
myTypeParams
11781178
}
11791179

1180+
override protected[dotc] final def info_=(tp: Type) = {
1181+
super.info_=(tp)
1182+
myTypeParams = null // changing the info might change decls, and with it typeParams
1183+
}
1184+
11801185
/** The denotations of all parents in this class. */
11811186
def classParents(implicit ctx: Context): List[TypeRef] = info match {
11821187
case classInfo: ClassInfo => classInfo.classParents

src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,18 @@ object Scala2Unpickler {
130130
} else {
131131
registerCompanionPair(scalacCompanion, denot.classSymbol)
132132
}
133+
val declsTypeParams = denot.typeParams
134+
val declsInRightOrder =
135+
if (declsTypeParams.corresponds(tparams)(_.name == _.name)) decls
136+
else { // create new scope with type parameters in right order
137+
val decls1 = newScope
138+
for (tparam <- tparams) decls1.enter(decls.lookup(tparam.name))
139+
for (sym <- decls) if (!declsTypeParams.contains(sym)) decls1.enter(sym)
140+
decls1
141+
}
133142

134-
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
143+
denot.info = ClassInfo(
144+
denot.owner.thisType, denot.classSymbol, parentRefs, declsInRightOrder, ost)
135145
}
136146
}
137147

0 commit comments

Comments
 (0)