Skip to content

Commit 138a04f

Browse files
committed
Delete Period.phaseId, force explicit use of first/last
1 parent e622291 commit 138a04f

File tree

8 files changed

+49
-30
lines changed

8 files changed

+49
-30
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ trait BCodeHelpers(val backendUtils: BackendUtils)(using ctx: Context) extends B
398398
atPhase(erasurePhase) {
399399
def computeMemberTpe(): Type =
400400
if (sym.is(Method)) sym.denot.info
401-
else if sym.denot.validFor.phaseId > erasurePhase.id && sym.isField && sym.getter.exists then
401+
else if sym.denot.validFor.firstPhaseId > erasurePhase.id && sym.isField && sym.getter.exists then
402402
// Memoization field of getter entered after erasure, see run/i17069 for an example
403403
sym.getter.denot.info.resultType
404404
else owner.denot.thisType.memberInfo(sym)

compiler/src/dotty/tools/backend/jvm/CoreBTypesFromSymbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ final class CoreBTypesFromSymbols(val ppa: PostProcessorFrontendAccess)(using va
211211
if (innerClassSym.isAnonymousClass || innerClassSym.isAnonymousFunction) None
212212
else {
213213
val original = innerClassSym.initial
214-
Some(atPhase(original.validFor.phaseId)(innerClassSym.name).mangledString) // moduleSuffix for module classes
214+
Some(atPhase(original.validFor.firstPhaseId)(innerClassSym.name).mangledString) // moduleSuffix for module classes
215215
}
216216
}
217217

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ object DottyBackendInterface {
8080
// for example by specialization
8181
val original = toDenot(sym).initial
8282
val validity = original.validFor
83-
atPhase(validity.phaseId) {
83+
atPhase(validity.firstPhaseId) {
8484
toDenot(sym).isStatic
8585
}
8686
}
@@ -90,7 +90,7 @@ object DottyBackendInterface {
9090
// it is very tricky in presence of classes(and anonymous classes) defined inside supper calls.
9191
if (sym.exists) {
9292
val validity = toDenot(sym).initial.validFor
93-
atPhase(validity.phaseId) {
93+
atPhase(validity.firstPhaseId) {
9494
toDenot(sym).lexicallyEnclosingClass
9595
}
9696
} else NoSymbol

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ object Contexts {
355355

356356
final def phase: Phase = base.phases(period.firstPhaseId)
357357
final def runId = period.runId
358-
final def phaseId = period.phaseId
358+
final def phaseId = period.firstPhaseId
359359

360360
final def lastPhaseId = base.phases.length - 1
361361

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ object Periods {
2626
val period = ctx.period
2727
period == p ||
2828
period.runId == p.runId &&
29-
unfusedPhases(period.phaseId).sameBaseTypesStartId ==
30-
unfusedPhases(p.phaseId).sameBaseTypesStartId
29+
unfusedPhases(period.firstPhaseId).sameBaseTypesStartId ==
30+
unfusedPhases(p.firstPhaseId).sameBaseTypesStartId
3131

3232
/** A period is a contiguous sequence of phase ids in some run.
3333
* It is coded as follows:
@@ -43,9 +43,6 @@ object Periods {
4343
/** The run identifier of this period. */
4444
def runId: RunId = code >>> (PhaseWidth * 2)
4545

46-
/** The phase identifier of this single-phase period. */
47-
def phaseId: PhaseId = firstPhaseId
48-
4946
/** The last phase of this period */
5047
def lastPhaseId: PhaseId = (code >>> PhaseWidth) & PhaseMask
5148

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,8 +2967,8 @@ object SymDenotations {
29672967
def isValidAt(phase: Phase)(using Context) =
29682968
checkedPeriod == ctx.period ||
29692969
createdAt.runId == ctx.runId &&
2970-
createdAt.phaseId < unfusedPhases.length &&
2971-
sameGroup(unfusedPhases(createdAt.phaseId), phase) &&
2970+
createdAt.firstPhaseId < unfusedPhases.length &&
2971+
sameGroup(unfusedPhases(createdAt.firstPhaseId), phase) &&
29722972
{ checkedPeriod = ctx.period; true }
29732973
}
29742974

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package dotty.tools.dotc.core
2+
3+
import org.junit.Assert.*
4+
import org.junit.Test
5+
6+
class PeriodsTest:
7+
import Periods._
8+
9+
val p1 = Period(1, 2, 7)
10+
val p2 = Period(1, 3, 7)
11+
12+
@Test def containsSubsetIsTrue() =
13+
assertTrue(p1.contains(p2))
14+
15+
@Test def containsSelfIsTrue() =
16+
assertTrue(p1.contains(p1))
17+
18+
@Test def containsSupersetIsFalse() =
19+
assertFalse(p2.contains(p1))
20+
21+
@Test def containsInvalidIsFalse() =
22+
assertFalse(p1.contains(Period(0, 3, 3)))
23+
24+
@Test def containsDifferentRunIsFalse() =
25+
assertFalse(p1.contains(Period(2, 3, 3)))
26+
27+
@Test def containsNowhereIsFalse() =
28+
assertFalse(p1.contains(Nowhere))
29+
30+
@Test def overlapsSelfIsTrue() =
31+
assertTrue(p1.overlaps(p1))
32+
33+
@Test def overlapsOverlappingIsTrue() =
34+
assertTrue(Period(1, 2, 7).overlaps(Period(1, 6, 9)))
35+
36+
@Test def overlapsNonOverlappingIsFalse() =
37+
assertTrue(Period(1, 2, 5).overlaps(Period(1, 6, 9)))
38+
39+
@Test def overlapsDifferentRunIsFalse() =
40+
assertTrue(Period(1, 2, 7).overlaps(Period(2, 6, 9)))

compiler/test/worksheets/periodtest.sc

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)