Skip to content

Commit 20d9b48

Browse files
committed
Fix safe-init errors in ContextBase
When bootstrapping the compiler with the `-Ysafe-init` flag, we would get the following errors: ``` [error] -- Error: /Users/********/dotty/compiler/src/dotty/tools/dotc/core/Phases.scala:164:19 [error] 164 | p.init(this, miniPhases.head.id, miniPhases.last.id) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace: [error] | -> usePhases(List(SomePhase)) [ Contexts.scala:876 ] [error] -- Error: /Users/********/dotty/compiler/src/dotty/tools/dotc/core/Phases.scala:161:30 [error] 161 | miniPhases.foreach{ phase => [error] | ^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. [error] | Calling trace: [error] | -> usePhases(List(SomePhase)) [ Contexts.scala:876 ] [error] | [error] |The unsafe promotion may cause the following problem: [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace: [error] | -> usePhases(List(SomePhase)) [ Contexts.scala:876 ] [error] 162 | checkRequirements(phase) [error] 163 | phase.init(this, nextPhaseId)} [error] -- Error: /Users/********/dotty/compiler/src/dotty/tools/dotc/core/Phases.scala:166:23 [error] 166 | phase.init(this, nextPhaseId) [error] | ^^^^ [error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace: [error] | -> usePhases(List(SomePhase)) [ Contexts.scala:876 ] ``` This fixes the initialization order to address these errors. Review by @liufengyun
1 parent 0b3dd14 commit 20d9b48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,12 @@ object Contexts {
872872
/** The loader that loads the members of _root_ */
873873
def rootLoader(root: TermSymbol)(using Context): SymbolLoader = platform.rootLoader(root)
874874

875-
// Set up some phases to get started */
876-
usePhases(List(SomePhase))
877-
878875
/** The standard definitions */
879876
val definitions: Definitions = new Definitions
880877

878+
// Set up some phases to get started */
879+
usePhases(List(SomePhase))
880+
881881
/** Initializes the `ContextBase` with a starting context.
882882
* This initializes the `platform` and the `definitions`.
883883
*/

0 commit comments

Comments
 (0)