Skip to content

Commit a6edd60

Browse files
committed
Make elim opaque transform declare that it changes base types
1 parent 207c380 commit a6edd60

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/core/Periods.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ abstract class Periods { self: Context =>
4343
val period = this.period
4444
period == p ||
4545
period.runId == p.runId &&
46-
this.phases(period.phaseId).sameParentsStartId ==
47-
this.phases(p.phaseId).sameParentsStartId
46+
this.phases(period.phaseId).sameBaseTypesStartId ==
47+
this.phases(p.phaseId).sameBaseTypesStartId
4848
}
4949
}
5050

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ object Phases {
320320
/** Can this transform change the parents of a class? */
321321
def changesParents: Boolean = false
322322

323+
/** Can this transform change the base types of a type? */
324+
def changesBaseTypes: Boolean = changesParents
325+
323326
def exists: Boolean = true
324327

325328
def initContext(ctx: FreshContext): Unit = ()
@@ -333,6 +336,7 @@ object Phases {
333336

334337
private[this] var mySameMembersStartId = NoPhaseId
335338
private[this] var mySameParentsStartId = NoPhaseId
339+
private[this] var mySameBaseTypesStartId = NoPhaseId
336340

337341
/** The sequence position of this phase in the given context where 0
338342
* is reserved for NoPhase and the first real phase is at position 1.
@@ -353,6 +357,8 @@ object Phases {
353357
// id of first phase where all symbols are guaranteed to have the same members as in this phase
354358
final def sameParentsStartId: Int = mySameParentsStartId
355359
// id of first phase where all symbols are guaranteed to have the same parents as in this phase
360+
final def sameBaseTypesStartId: Int = mySameBaseTypesStartId
361+
// id of first phase where all symbols are guaranteed to have the same base tpyes as in this phase
356362

357363
protected[Phases] def init(base: ContextBase, start: Int, end: Int): Unit = {
358364
if (start >= FirstPhaseId)
@@ -366,6 +372,7 @@ object Phases {
366372
myLabelsReordered = prev.getClass == classOf[LabelDefs] || prev.labelsReordered
367373
mySameMembersStartId = if (changesMembers) id else prev.sameMembersStartId
368374
mySameParentsStartId = if (changesParents) id else prev.sameParentsStartId
375+
mySameBaseTypesStartId = if (changesBaseTypes) id else prev.sameBaseTypesStartId
369376
}
370377

371378
protected[Phases] def init(base: ContextBase, id: Int): Unit = init(base, id, id)

compiler/src/dotty/tools/dotc/transform/FirstTransform.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class FirstTransform extends MiniPhase with SymTransformer { thisPhase =>
4242
import ast.tpd._
4343

4444
override def phaseName: String = FirstTransform.name
45+
override def changesBaseTypes: Boolean = true // the phase gives new base types for opaques
4546

4647
/** Two transforms:
4748
* 1. eliminate self symbol in ClassInfo

0 commit comments

Comments
 (0)