diff --git a/effekt/jvm/src/main/scala/effekt/Driver.scala b/effekt/jvm/src/main/scala/effekt/Driver.scala index 0b85d2bf8b..5a86c066a8 100644 --- a/effekt/jvm/src/main/scala/effekt/Driver.scala +++ b/effekt/jvm/src/main/scala/effekt/Driver.scala @@ -82,7 +82,7 @@ trait Driver extends kiama.util.Compiler[EffektConfig, EffektError] { outer => } // we are in one of three exclusive modes: LSPServer, Compile, Run - if (config.server()) { compiler.runFrontend(src) } + if (config.server()) { compiler.runMiddleend(src) } else if (config.interpret()) { compile() foreach runner.eval } else if (config.build()) { compile() foreach runner.build } else if (config.compile()) { compile() } diff --git a/effekt/shared/src/main/scala/effekt/Compiler.scala b/effekt/shared/src/main/scala/effekt/Compiler.scala index 4f94475ed8..9962e53bad 100644 --- a/effekt/shared/src/main/scala/effekt/Compiler.scala +++ b/effekt/shared/src/main/scala/effekt/Compiler.scala @@ -125,6 +125,14 @@ trait Compiler[Executable] { mod } + def runMiddleend(source: Source)(using Context): Option[Typechecked] = + (Parser andThen + Namer andThen + BoxUnboxInference andThen + Typer andThen + Wellformedness andThen + AnnotateCaptures)(source) + /** * Called after running the frontend from editor services. * diff --git a/effekt/shared/src/main/scala/effekt/source/AnnotateCaptures.scala b/effekt/shared/src/main/scala/effekt/source/AnnotateCaptures.scala index 76ed621e34..8122a58cfa 100644 --- a/effekt/shared/src/main/scala/effekt/source/AnnotateCaptures.scala +++ b/effekt/shared/src/main/scala/effekt/source/AnnotateCaptures.scala @@ -112,6 +112,8 @@ object AnnotateCaptures extends Phase[Typechecked, Typechecked], Query[Unit, Cap def annotate(tree: source.ModuleDecl, src: Source)(using Context): Unit = given Unit = (); + // reset allCaptures since multiple runs of this Phase may pollute it with outdated information + allCaptures = Nil query(tree) Context.annotate(Annotations.CaptureForFile, src, allCaptures)