Skip to content

Commit eaf39cb

Browse files
Run all java checks after typechecking
1 parent 34a2fea commit eaf39cb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/typer/FrontEnd.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ class FrontEnd extends Phase {
8080
typr.println("typed: " + unit.source)
8181
record("retained untyped trees", unit.untpdTree.treeSize)
8282
record("retained typed trees after typer", unit.tpdTree.treeSize)
83-
if unit.isJava then
84-
JavaChecks.check(unit.tpdTree)
8583
catch
8684
case ex: CompilationUnit.SuspendException =>
8785
}
8886

87+
def javaCheck(using Context): Unit = monitor("checking java") {
88+
val unit = ctx.compilationUnit
89+
if unit.isJava then
90+
JavaChecks.check(unit.tpdTree)
91+
}
92+
93+
8994
private def firstTopLevelDef(trees: List[tpd.Tree])(using Context): Symbol = trees match {
9095
case PackageDef(_, defs) :: _ => firstTopLevelDef(defs)
9196
case Import(_, _) :: defs => firstTopLevelDef(defs)
@@ -115,6 +120,8 @@ class FrontEnd extends Phase {
115120

116121
unitContexts.foreach(typeCheck(using _))
117122
record("total trees after typer", ast.Trees.ntrees)
123+
unitContexts.foreach(javaCheck(using _)) // after typechecking to avoid cycles
124+
118125
val newUnits = unitContexts.map(_.compilationUnit).filterNot(discardAfterTyper)
119126
val suspendedUnits = ctx.run.suspendedUnits
120127
if newUnits.isEmpty && suspendedUnits.nonEmpty && !ctx.reporter.errorsReported then

0 commit comments

Comments
 (0)