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