@@ -20,6 +20,7 @@ import java.io.{BufferedWriter, OutputStreamWriter}
2020import printing .XprintMode
2121import parsing .Parsers .Parser
2222import typer .ImplicitRunInfo
23+ import collection .mutable
2324
2425import scala .annotation .tailrec
2526import dotty .tools .io .VirtualFile
@@ -68,6 +69,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
6869 private [this ] var myUnitsCached : List [CompilationUnit ] = _
6970 private [this ] var myFiles : Set [AbstractFile ] = _
7071
72+ /** Units that are added because of source completers but that are not
73+ * compiled in current run.
74+ */
75+ val lateUnits = mutable.ListBuffer [CompilationUnit ]()
76+ var lateFiles = mutable.Set [AbstractFile ]()
77+
7178 /** The compilation units currently being compiled, this may return different
7279 * results over time.
7380 */
@@ -175,8 +182,10 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
175182 * The newly added symbols replace any previously entered symbols.
176183 */
177184 def enterRoots (file : AbstractFile )(implicit ctx : Context ): Unit =
178- if (! files.contains(file)) {
185+ if (! files.contains(file) && ! lateFiles.contains(file) ) {
179186 val unit = new CompilationUnit (getSource(file.path))
187+ lateUnits += unit
188+ lateFiles += file
180189 enterRoots(unit)(runContext.fresh.setCompilationUnit(unit))
181190 }
182191
0 commit comments