@@ -9,9 +9,9 @@ import DenotTransformers.*
9
9
import Denotations .*
10
10
import Decorators .*
11
11
import config .Printers .config
12
- import scala .collection .mutable .ListBuffer
13
12
import dotty .tools .dotc .transform .MegaPhase .*
14
13
import dotty .tools .dotc .transform .*
14
+ import dotty .tools .dotc .util .chaining .*
15
15
import Periods .*
16
16
import parsing .Parser
17
17
import printing .XprintMode
@@ -20,8 +20,9 @@ import cc.CheckCaptures
20
20
import typer .ImportInfo .withRootImports
21
21
import ast .{tpd , untpd }
22
22
import scala .annotation .internal .sharable
23
- import scala .util . control . NonFatal
23
+ import scala .collection . mutable . ListBuffer
24
24
import scala .compiletime .uninitialized
25
+ import scala .util .control .NonFatal
25
26
26
27
object Phases {
27
28
@@ -58,15 +59,15 @@ object Phases {
58
59
final def phasePlan : List [List [Phase ]] = this .phasesPlan
59
60
final def setPhasePlan (phasess : List [List [Phase ]]): Unit = this .phasesPlan = phasess
60
61
61
- /** Squash TreeTransform's beloning to same sublist to a single TreeTransformer
62
- * Each TreeTransform gets own period,
63
- * whereas a combined TreeTransformer gets period equal to union of periods of it's TreeTransforms
64
- */
62
+ /** Squash TreeTransforms belonging to same sublist to a single TreeTransformer.
63
+ * Each TreeTransform gets its own period,
64
+ * whereas a combined TreeTransformer gets period equal to union of periods of its TreeTransforms.
65
+ */
65
66
final def fusePhases (phasess : List [List [Phase ]],
66
67
phasesToSkip : List [String ],
67
68
stopBeforePhases : List [String ],
68
69
stopAfterPhases : List [String ],
69
- YCheckAfter : List [String ])(using Context ): List [Phase ] = {
70
+ checkAfter : List [String ])(using Context ): List [Phase ] = {
70
71
val fusedPhases = ListBuffer [Phase ]()
71
72
var prevPhases : Set [String ] = Set .empty
72
73
@@ -110,7 +111,7 @@ object Phases {
110
111
phase
111
112
}
112
113
fusedPhases += phaseToAdd
113
- val shouldAddYCheck = filteredPhases(i).exists(_.isCheckable) && YCheckAfter .containsPhase(phaseToAdd)
114
+ val shouldAddYCheck = filteredPhases(i).exists(_.isCheckable) && checkAfter .containsPhase(phaseToAdd)
114
115
if (shouldAddYCheck) {
115
116
val checker = new TreeChecker
116
117
fusedPhases += checker
@@ -130,10 +131,9 @@ object Phases {
130
131
131
132
val flatPhases = ListBuffer .empty[Phase ]
132
133
133
- phasess.foreach {
134
+ phasess.foreach:
134
135
case p : MegaPhase => flatPhases ++= p.miniPhases
135
136
case p => flatPhases += p
136
- }
137
137
138
138
phases = (NoPhase :: flatPhases.toList ::: new TerminalPhase :: Nil ).toArray
139
139
setSpecificPhases()
@@ -565,23 +565,26 @@ object Phases {
565
565
current.map(_.flatMap(phase =>
566
566
if (oldPhaseClass.isInstance(phase)) newPhases(phase) else phase :: Nil ))
567
567
568
- def assemblePhases ()(using Context ): FreshContext =
569
- val runCtx = ctx.fresh
570
-
568
+ def assemblePhases ()(using Context ): FreshContext = ctx.fresh.tap: runCtx =>
571
569
// If testing pickler, make sure to stop after pickling phase:
572
570
val stopAfter =
573
- if ( ctx.settings.YtestPickler .value) List (" pickler" )
571
+ if ctx.settings.YtestPickler .value then List (" pickler" )
574
572
else ctx.settings.YstopAfter .value
575
573
576
574
val pluginPlan = ctx.base.addPluginPhases(ctx.base.phasePlan)
577
575
val phases = ctx.base.fusePhases(pluginPlan,
578
- ctx.settings.Yskip .value, ctx.settings.YstopBefore .value, stopAfter, ctx.settings.Ycheck .value)
576
+ phasesToSkip = ctx.settings.Yskip .value,
577
+ stopBeforePhases = ctx.settings.YstopBefore .value,
578
+ stopAfterPhases = stopAfter,
579
+ checkAfter = ctx.settings.Ycheck .value)
579
580
ctx.base.usePhases(phases, runCtx)
580
581
581
- val phasesSettings = List (" -Vphases" , " -Vprint" )
582
- for phasesSetting <- ctx.settings.allSettings if phasesSettings.contains(phasesSetting.name) do
583
- for case vs : List [String ] <- phasesSetting.userValue; p <- vs do
582
+ val phasesSettings =
583
+ val ss = ctx.settings
584
+ import ss .*
585
+ List (Vprint ) // no check for Vphases
586
+ for phasesSetting <- phasesSettings do
587
+ for case ps : List [String ] <- phasesSetting.userValue; p <- ps do
584
588
if ! phases.exists(List (p).containsPhase) then report.warning(s " ' $p' specifies no phase " )
585
- runCtx
586
589
end assemblePhases
587
590
}
0 commit comments