@@ -13,10 +13,12 @@ import scala.collection.mutable.ListBuffer
13
13
import dotty .tools .dotc .transform .MegaPhase ._
14
14
import dotty .tools .dotc .transform ._
15
15
import Periods ._
16
- import typer .{FrontEnd , RefChecks }
16
+ import parsing .{ Parser }
17
+ import typer .{TyperPhase , RefChecks }
17
18
import typer .ImportInfo .withRootImports
18
19
import ast .tpd
19
20
import scala .annotation .internal .sharable
21
+ import scala .util .control .NonFatal
20
22
21
23
object Phases {
22
24
@@ -64,7 +66,6 @@ object Phases {
64
66
YCheckAfter : List [String ])(using Context ): List [Phase ] = {
65
67
val fusedPhases = ListBuffer [Phase ]()
66
68
var prevPhases : Set [String ] = Set .empty
67
- val YCheckAll = YCheckAfter .contains(" all" )
68
69
69
70
var stop = false
70
71
@@ -106,7 +107,7 @@ object Phases {
106
107
phase
107
108
}
108
109
fusedPhases += phaseToAdd
109
- val shouldAddYCheck = YCheckAfter .containsPhase(phaseToAdd) || YCheckAll
110
+ val shouldAddYCheck = filteredPhases(i).exists(_.isCheckable) && YCheckAfter .containsPhase(phaseToAdd)
110
111
if (shouldAddYCheck) {
111
112
val checker = new TreeChecker
112
113
fusedPhases += checker
@@ -194,6 +195,7 @@ object Phases {
194
195
config.println(s " nextDenotTransformerId = ${nextDenotTransformerId.toList}" )
195
196
}
196
197
198
+ private var myParserPhase : Phase = _
197
199
private var myTyperPhase : Phase = _
198
200
private var myPostTyperPhase : Phase = _
199
201
private var mySbtExtractDependenciesPhase : Phase = _
@@ -215,6 +217,7 @@ object Phases {
215
217
private var myFlattenPhase : Phase = _
216
218
private var myGenBCodePhase : Phase = _
217
219
220
+ final def parserPhase : Phase = myParserPhase
218
221
final def typerPhase : Phase = myTyperPhase
219
222
final def postTyperPhase : Phase = myPostTyperPhase
220
223
final def sbtExtractDependenciesPhase : Phase = mySbtExtractDependenciesPhase
@@ -239,7 +242,8 @@ object Phases {
239
242
private def setSpecificPhases () = {
240
243
def phaseOfClass (pclass : Class [? ]) = phases.find(pclass.isInstance).getOrElse(NoPhase )
241
244
242
- myTyperPhase = phaseOfClass(classOf [FrontEnd ])
245
+ myParserPhase = phaseOfClass(classOf [Parser ])
246
+ myTyperPhase = phaseOfClass(classOf [TyperPhase ])
243
247
myPostTyperPhase = phaseOfClass(classOf [PostTyper ])
244
248
mySbtExtractDependenciesPhase = phaseOfClass(classOf [sbt.ExtractDependencies ])
245
249
myPicklerPhase = phaseOfClass(classOf [Pickler ])
@@ -262,6 +266,7 @@ object Phases {
262
266
}
263
267
264
268
final def isAfterTyper (phase : Phase ): Boolean = phase.id > typerPhase.id
269
+ final def isTyper (phase : Phase ): Boolean = phase.id == typerPhase.id
265
270
}
266
271
267
272
abstract class Phase {
@@ -313,8 +318,8 @@ object Phases {
313
318
*/
314
319
def checkPostCondition (tree : tpd.Tree )(using Context ): Unit = ()
315
320
316
- /** Is this phase the standard typerphase? True for FrontEnd , but
317
- * not for other first phases (such as FromTasty). The predicate
321
+ /** Is this phase the standard typerphase? True for TyperPhase , but
322
+ * not for other first phases (such as FromTasty or Parser ). The predicate
318
323
* is tested in some places that perform checks and corrections. It's
319
324
* different from ctx.isAfterTyper (and cheaper to test).
320
325
*/
@@ -402,9 +407,17 @@ object Phases {
402
407
final def iterator : Iterator [Phase ] =
403
408
Iterator .iterate(this )(_.next) takeWhile (_.hasNext)
404
409
410
+ final def monitor (doing : String )(body : => Unit )(using Context ): Unit =
411
+ try body
412
+ catch
413
+ case NonFatal (ex) =>
414
+ report.echo(s " exception occurred while $doing ${ctx.compilationUnit}" )
415
+ throw ex
416
+
405
417
override def toString : String = phaseName
406
418
}
407
419
420
+ def parserPhase (using Context ): Phase = ctx.base.parserPhase
408
421
def typerPhase (using Context ): Phase = ctx.base.typerPhase
409
422
def postTyperPhase (using Context ): Phase = ctx.base.postTyperPhase
410
423
def sbtExtractDependenciesPhase (using Context ): Phase = ctx.base.sbtExtractDependenciesPhase
0 commit comments