@@ -393,38 +393,42 @@ object Inlines:
393
393
case ConstantType (Constant (code : String )) =>
394
394
val unitName = " tasty-reflect"
395
395
val source2 = SourceFile .virtual(unitName, code)
396
+ def compilationUnits (untpdTree : untpd.Tree , tpdTree : Tree ): List [CompilationUnit ] =
397
+ val compilationUnit = CompilationUnit (unitName, code)
398
+ compilationUnit.tpdTree = tpdTree
399
+ compilationUnit.untpdTree = untpdTree
400
+ List (compilationUnit)
396
401
// We need a dummy owner, as the actual one does not have a computed denotation yet,
397
402
// but might be inspected in a transform phase, leading to cyclic errors
398
403
val dummyOwner = newSymbol(ctx.owner, " $dummySymbol$" .toTermName, Private , defn.AnyType , NoSymbol )
399
404
val newContext =
400
405
ctx.fresh.setNewTyperState().setTyper(new Typer (ctx.nestingLevel + 1 )).setSource(source2)
401
406
402
407
inContext(newContext) {
403
- val tree2 = new Parser (source2).block()
404
- if ctx.reporter.allErrors.nonEmpty then
408
+ def noErrors = ctx.reporter.allErrors.isEmpty
409
+ val untpdTree = new Parser (source2).block()
410
+ if ! noErrors then
405
411
ctx.reporter.allErrors.map((ErrorKind .Parser , _))
406
412
else
407
- val tree3 = ctx.typer.typed(tree2 )
413
+ val tpdTree1 = ctx.typer.typed(untpdTree )
408
414
ctx.base.postTyperPhase match
409
- case postTyper : PostTyper if ctx.reporter.allErrors.isEmpty =>
410
- val tree4 = atPhase(postTyper) { postTyper.newTransformer.transform(tree3) }
415
+ case postTyper : PostTyper if noErrors =>
416
+ val tpdTree2 =
417
+ atPhase(postTyper) { postTyper.runOn(compilationUnits(untpdTree, tpdTree1)).head.tpdTree }
411
418
ctx.base.setRootTreePhase match
412
- case setRootTree =>
413
- val tree5 =
414
- val compilationUnit = CompilationUnit (unitName, code)
415
- compilationUnit.tpdTree = tree4
416
- compilationUnit.untpdTree = tree2
417
- var units = List (compilationUnit)
418
- atPhase(setRootTree)(setRootTree.runOn(units).head.tpdTree)
419
+ case setRootTree if noErrors => // might be noPhase, if -Yretain-trees is not used
420
+ val tpdTree3 =
421
+ atPhase(setRootTree)(setRootTree.runOn(compilationUnits(untpdTree, tpdTree2)).head.tpdTree)
419
422
ctx.base.inliningPhase match
420
- case inlining : Inlining if ctx.reporter.allErrors.isEmpty =>
421
- val tree6 = atPhase(inlining) { inlining.newTransformer.transform(tree5 ) }
422
- if ctx.reporter.allErrors.isEmpty && reconstructedTransformPhases.nonEmpty then
423
- var transformTree = tree6
423
+ case inlining : Inlining if noErrors =>
424
+ val tpdTree4 = atPhase(inlining) { inlining.newTransformer.transform(tpdTree3 ) }
425
+ if noErrors && reconstructedTransformPhases.nonEmpty then
426
+ var transformTree = tpdTree4
424
427
for phase <- reconstructedTransformPhases do
425
- if ctx.reporter.allErrors.isEmpty then
428
+ if noErrors then
426
429
transformTree = atPhase(phase.end + 1 )(phase.transformUnit(transformTree))
427
430
case _ =>
431
+ case _ =>
428
432
case _ =>
429
433
ctx.reporter.allErrors.map((ErrorKind .Typer , _))
430
434
}
0 commit comments