Skip to content

Commit 00cd39a

Browse files
committed
Make superId management depend on TypeRefs instead of ClassSymbols.
Reason: Symbols may change on each run; TypeRefs do not.
1 parent 5ec4e3d commit 00cd39a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ object Contexts {
149149

150150
def nextId = { _nextId += 1; _nextId }
151151

152-
/** A map from a superclass id to the class that has it */
153-
private[core] var classOfId = new Array[ClassSymbol](InitialSuperIdsSize)
152+
/** A map from a superclass id to the type-ref of the class that has it */
153+
private[core] var classOfId = new Array[TypeRef](InitialSuperIdsSize)
154154

155-
/** A map from a superclass to its superclass id */
156-
private[core] val superIdOfClass = new mutable.HashMap[ClassSymbol, Int]
155+
/** A map from a the type-ref of a superclass to its superclass id */
156+
private[core] val superIdOfClass = new mutable.HashMap[TypeRef, Int]
157157

158158
/** The last allocate superclass id */
159159
private[core] var lastSuperId = -1
@@ -162,7 +162,7 @@ object Contexts {
162162
private[core] def nextSuperId: Int = {
163163
lastSuperId += 1;
164164
if (lastSuperId >= classOfId.length) {
165-
val tmp = new Array[ClassSymbol](classOfId.length * 2)
165+
val tmp = new Array[TypeRef](classOfId.length * 2)
166166
classOfId.copyToArray(tmp)
167167
classOfId = tmp
168168
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,16 @@ object Symbols {
185185

186186
def superId(implicit ctx: Context): Int = {
187187
val hint = superIdHint
188-
if (hint >= 0 && hint <= ctx.lastSuperId && (ctx.classOfId(hint) eq this)) hint
188+
val key = this.typeConstructor
189+
if (hint >= 0 && hint <= ctx.lastSuperId && (ctx.classOfId(hint) eq key)) hint
189190
else {
190-
val id = ctx.superIdOfClass get this match {
191+
val id = ctx.superIdOfClass get key match {
191192
case Some(id) =>
192193
id
193194
case None =>
194195
val id = ctx.nextSuperId
195-
ctx.superIdOfClass(this) = id
196-
ctx.classOfId(id) = this
196+
ctx.superIdOfClass(key) = id
197+
ctx.classOfId(id) = key
197198
id
198199
}
199200
superIdHint = id

0 commit comments

Comments
 (0)