@@ -18,6 +18,8 @@ import tpd.tpes
18
18
import Variances .alwaysInvariant
19
19
import config .{Config , Feature }
20
20
import config .Printers .typr
21
+ import parsing .JavaParsers .JavaParser
22
+ import parsing .Parsers .Parser
21
23
import Annotations ._
22
24
import Inferencing ._
23
25
import transform .ValueClasses ._
@@ -708,15 +710,41 @@ class Namer { typer: Typer =>
708
710
ctxWithStats
709
711
}
710
712
711
- /** Index symbols in `tree` while asserting the `lateCompile` flag.
712
- * This will cause any old top-level symbol with the same fully qualified
713
- * name as a newly created symbol to be replaced.
714
- */
715
- def lateEnter (tree : Tree )(using Context ): Context = {
716
- val saved = lateCompile
717
- lateCompile = true
718
- try index(tree :: Nil ) finally lateCompile = saved
719
- }
713
+
714
+ def lateEnterUnit (typeCheckCB : (() => Unit ) => Unit )(using Context ) =
715
+ val unit = ctx.compilationUnit
716
+
717
+ /** Index symbols in `tree` while asserting the `lateCompile` flag.
718
+ * This will cause any old top-level symbol with the same fully qualified
719
+ * name as a newly created symbol to be replaced.
720
+ */
721
+ def lateEnter ()(using Context ): Context = {
722
+ val saved = lateCompile
723
+ lateCompile = true
724
+ try index(unit.untpdTree :: Nil ) finally lateCompile = saved
725
+ }
726
+
727
+ /** Set the tpdTree and root tree of the compilation unit
728
+ */
729
+ def lateTypeCheck ()(using Context ) =
730
+ unit.tpdTree = typer.typedExpr(unit.untpdTree)
731
+ val phase = new transform.SetRootTree ()
732
+ phase.run
733
+
734
+ unit.untpdTree =
735
+ if (unit.isJava) new JavaParser (unit.source).parse()
736
+ else new Parser (unit.source).parse()
737
+
738
+ inContext(PrepareInlineable .initContext(ctx)) {
739
+ // inline body annotations are set in namer, capturing the current context
740
+ // we need to prepare the context for inlining.
741
+ lateEnter()
742
+ typeCheckCB { () =>
743
+ atPhase(Phases .typerPhase) {
744
+ lateTypeCheck()
745
+ }
746
+ }
747
+ }
720
748
721
749
/** The type bound on wildcard imports of an import list, with special values
722
750
* Nothing if no wildcard imports of this kind exist
0 commit comments