Skip to content

Commit f17e4d5

Browse files
committed
Fix safe-init error in MegaPhase
When bootstrapping the compiler with the `-Ysafe-init` flag, we would get the following error: ``` [error] -- Error: /Users/rrampersad/Documents/school/URA/dotty/compiler/src/dotty/tools/dotc/transform/MegaPhase.scala:458:7 [error] 458 | for ((phase, idx) <- miniPhases.zipWithIndex) { [error] | ^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] | [error] |The unsafe promotion may cause the following problem: [error] |Cannot prove that the value is fully initialized. May only assign fully initialized value. [error] 459 | phase.superPhase = this [error] 460 | phase.idxInGroup = idx [error] 461 | } ``` This fixes the initialization order to address this error.
1 parent b472e26 commit f17e4d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,6 @@ class MegaPhase(val miniPhases: Array[MiniPhase]) extends Phase {
455455

456456
// Initialization code
457457

458-
for ((phase, idx) <- miniPhases.zipWithIndex) {
459-
phase.superPhase = this
460-
phase.idxInGroup = idx
461-
}
462-
463458
/** Class#getDeclaredMethods is slow, so we cache its output */
464459
private val clsMethodsCache = new java.util.IdentityHashMap[Class[?], Array[java.lang.reflect.Method]]
465460

@@ -564,6 +559,11 @@ class MegaPhase(val miniPhases: Array[MiniPhase]) extends Phase {
564559
private val nxOtherPrepPhase = init("prepareForOther")
565560
private val nxOtherTransPhase = init("transformOther")
566561

562+
for ((phase, idx) <- miniPhases.zipWithIndex) {
563+
phase.superPhase = this
564+
phase.idxInGroup = idx
565+
}
566+
567567
// Boilerplate snippets
568568

569569
def prepIdent(tree: Ident, start: Int)(using Context): Context = {

0 commit comments

Comments
 (0)