Our LSP reuses unchanged sources and only compiles changed ones. So there exist a scenario where the file containing primitive declarations (for example, Primitives.aya) can be unchanged while its importers are modified by users --- in this case, the recompile list does not contain Primitives.aya so primitives previously created and stored in the factory should be reused, thus we cannot clear the primitive factory after every recompilation.
Unfortunately, the original primitive factory does not fit our needs in the situation described above, which always reports redefinition errors because it is not designed to be used in an incremental compiler.
Patches in this file is safe (no definition leak). This can be proven by case-split:
When Primitives.aya is unchanged, the InMemoryCompilerAdvisor
keeps track of the last compilation result (namely ResolveInfo), which ensures the
re-resolve of changed source files always points primitives to the previously created PrimDefs.
When Primitives.aya is changed, the LibraryCompiler will recompile it together with
its importers, which is a full remake of all primitive-related source files and the
InMemoryCompilerAdvisor will be updated to the newest compilation result.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull org.aya.core.def.PrimDeffactory(@NotNull org.aya.core.def.PrimDef.ID name, @NotNull org.aya.ref.DefVar<org.aya.core.def.PrimDef, org.aya.concrete.stmt.decl.TeleDecl.PrimDecl> ref) booleanMethods inherited from class org.aya.core.def.PrimDef.Factory
checkDependency, clear, clear, getCall, getCall, getOption, getOrCreate, have, unfold
-
Constructor Details
-
LspPrimFactory
public LspPrimFactory()
-
-
Method Details
-
suppressRedefinition
public boolean suppressRedefinition()- Overrides:
suppressRedefinitionin classorg.aya.core.def.PrimDef.Factory
-
factory
@NotNull public @NotNull org.aya.core.def.PrimDef factory(@NotNull org.aya.core.def.PrimDef.ID name, @NotNull @NotNull org.aya.ref.DefVar<org.aya.core.def.PrimDef, org.aya.concrete.stmt.decl.TeleDecl.PrimDecl> ref) - Overrides:
factoryin classorg.aya.core.def.PrimDef.Factory
-