@@ -312,21 +312,26 @@ object Inliner {
312
312
ConstFold (underlyingCodeArg).tpe.widenTermRefExpr match {
313
313
case ConstantType (Constant (code : String )) =>
314
314
val source2 = SourceFile .virtual(" tasty-reflect" , code)
315
- val ctx2 = ctx.fresh.setNewTyperState().setTyper(new Typer ).setSource(source2)
316
- val tree2 = new Parser (source2)(using ctx2).block()
317
- val res = collection.mutable.ListBuffer .empty[(ErrorKind , Error )]
318
-
319
- val parseErrors = ctx2.reporter.allErrors.toList
320
- res ++= parseErrors.map(e => ErrorKind .Parser -> e)
321
- if res.isEmpty then
322
- val tree3 = ctx2.typer.typed(tree2)(using ctx2)
323
- val postTyper = ctx.base.postTyperPhase.asInstanceOf [PostTyper ]
324
- val tree4 = postTyper.newTransformer.transform(tree3)(using ctx2.withPhase(postTyper))
325
- val inlining = ctx.base.inliningPhase.asInstanceOf [Inlining ]
326
- inlining.newTransformer.transform(tree4)(using ctx2.withPhase(inlining))
327
- val typerErrors = ctx2.reporter.allErrors.filterNot(parseErrors.contains)
328
- res ++= typerErrors.map(e => ErrorKind .Typer -> e)
329
- res.toList
315
+ inContext(ctx.fresh.setNewTyperState().setTyper(new Typer ).setSource(source2)) {
316
+ val tree2 = new Parser (source2).block()
317
+ val res = collection.mutable.ListBuffer .empty[(ErrorKind , Error )]
318
+
319
+ val parseErrors = ctx.reporter.allErrors.toList
320
+ res ++= parseErrors.map(e => ErrorKind .Parser -> e)
321
+ if res.isEmpty then
322
+ val tree3 = ctx.typer.typed(tree2)
323
+ ctx.base.postTyperPhase match
324
+ case postTyper : PostTyper =>
325
+ val tree4 = atPhase(postTyper) { postTyper.newTransformer.transform(tree3) }
326
+ ctx.base.inliningPhase match
327
+ case inlining : Inlining =>
328
+ val tree5 = atPhase(inlining) { inlining.newTransformer.transform(tree4) }
329
+ case _ =>
330
+ case _ =>
331
+ val typerErrors = ctx.reporter.allErrors.filterNot(parseErrors.contains)
332
+ res ++= typerErrors.map(e => ErrorKind .Typer -> e)
333
+ res.toList
334
+ }
330
335
case t =>
331
336
report.error(em " argument to compileError must be a statically known String but was: $codeArg" , codeArg1.srcPos)
332
337
Nil
0 commit comments