@@ -353,6 +353,36 @@ object Inlines:
353
353
override def end : Int = endId
354
354
}
355
355
356
+ // Let's reconstruct necessary transform MegaPhases, without anything
357
+ // that could cause problems here (like `CrossVersionChecks`).
358
+ // The individiual lists here should line up with Compiler.scala, i.e
359
+ // separate chunks there should also be kept separate here.
360
+ // For now we create a single MegaPhase, since there does not seem to
361
+ // be any important checks later (e.g. ForwardDepChecks could be applicable here,
362
+ // but the equivalent is also not run in the scala 2's `ctx.typechecks`,
363
+ // so let's leave it out for now).
364
+ lazy val reconstructedTransformPhases =
365
+ val transformPhases : List [List [(Class [? ], () => MiniPhase )]] = List (
366
+ List (
367
+ (classOf [InlineVals ], () => new InlineVals ),
368
+ (classOf [ElimRepeated ], () => new ElimRepeated ),
369
+ (classOf [RefChecks ], () => new RefChecks ),
370
+ ),
371
+ )
372
+
373
+ transformPhases.flatMap( (megaPhaseList : List [(Class [? ], () => MiniPhase )]) =>
374
+ val (newMegaPhasePhases, phaseIds) =
375
+ megaPhaseList.flatMap {
376
+ case (filteredPhaseClass, miniphaseConstructor) =>
377
+ ctx.base.phases
378
+ .find(phase => filteredPhaseClass.isInstance(phase))
379
+ .map(phase => (miniphaseConstructor(), phase.id))
380
+ }
381
+ .unzip
382
+ if newMegaPhasePhases.isEmpty then None
383
+ else Some (MegaPhaseWithCustomPhaseId (newMegaPhasePhases.toArray, phaseIds.head, phaseIds.last))
384
+ )
385
+
356
386
ConstFold (underlyingCodeArg).tpe.widenTermRefExpr match {
357
387
case ConstantType (Constant (code : String )) =>
358
388
val unitName = " tasty-reflect"
@@ -364,36 +394,6 @@ object Inlines:
364
394
ctx.fresh.setNewTyperState().setTyper(new Typer (ctx.nestingLevel + 1 )).setSource(source2)
365
395
366
396
inContext(newContext) {
367
- // Let's reconstruct necessary transform MegaPhases, without anything
368
- // that could cause problems here (like `CrossVersionChecks`).
369
- // The individiual lists here should line up with Compiler.scala, i.e
370
- // separate chunks there should also be kept separate here.
371
- // For now we create a single MegaPhase, since there does not seem to
372
- // be any important checks later (e.g. ForwardDepChecks could be applicable here,
373
- // but the equivalent is also not run in the scala 2's `ctx.typechecks`,
374
- // so let's leave it out for now).
375
- val transformPhases : List [List [(Class [? ], () => MiniPhase )]] = List (
376
- List (
377
- (classOf [InlineVals ], () => new InlineVals ),
378
- (classOf [ElimRepeated ], () => new ElimRepeated ),
379
- (classOf [RefChecks ], () => new RefChecks ),
380
- ),
381
- )
382
-
383
- val mergedTransformPhases =
384
- transformPhases.flatMap( (megaPhaseList : List [(Class [? ], () => MiniPhase )]) =>
385
- val (newMegaPhasePhases, phaseIds) =
386
- megaPhaseList
387
- .flatMap { filteredPhase =>
388
- ctx.base.phases.find(phase => filteredPhase._1.isInstance(phase)).map { a =>
389
- (filteredPhase._2(), a.id)
390
- }
391
- }
392
- .unzip
393
- if newMegaPhasePhases.isEmpty then None
394
- else Some (MegaPhaseWithCustomPhaseId (newMegaPhasePhases.toArray, phaseIds.head, phaseIds.last))
395
- )
396
-
397
397
val tree2 = new Parser (source2).block()
398
398
if ctx.reporter.allErrors.nonEmpty then
399
399
ctx.reporter.allErrors.map((ErrorKind .Parser , _))
@@ -410,15 +410,14 @@ object Inlines:
410
410
compilationUnit.untpdTree = tree2
411
411
var units = List (compilationUnit)
412
412
atPhase(setRootTree)(setRootTree.runOn(units).head.tpdTree)
413
-
414
413
ctx.base.inliningPhase match
415
414
case inlining : Inlining if ctx.reporter.allErrors.isEmpty =>
416
415
val tree6 = atPhase(inlining) { inlining.newTransformer.transform(tree5) }
417
- if mergedTransformPhases .nonEmpty then
416
+ if ctx.reporter.allErrors.isEmpty && reconstructedTransformPhases .nonEmpty then
418
417
var transformTree = tree6
419
- for ( phase <- mergedTransformPhases if ctx.reporter.allErrors.isEmpty) {
420
- transformTree = atPhase(phase.end + 1 )(phase.transformUnit(transformTree))
421
- }
418
+ for phase <- reconstructedTransformPhases do
419
+ if ctx.reporter.allErrors.isEmpty then
420
+ transformTree = atPhase(phase.end + 1 )(phase.transformUnit(transformTree))
422
421
case _ =>
423
422
case _ =>
424
423
ctx.reporter.allErrors.map((ErrorKind .Typer , _))
0 commit comments