[REPL] Fix unresolved imports caching

Before this fix, if some imports were not resolved during compilation,
this result had been saved in caches, and this import couldn't been
resolved during following compilations even if it was added to the
module dependencies. This commit adds special handling of resolution
caches for the REPL compiler.
This commit is contained in:
Ilya Muradyan
2021-03-22 14:20:36 +03:00
parent ae5fefce51
commit 14d386223b
12 changed files with 179 additions and 27 deletions
@@ -296,6 +296,12 @@ class JvmIdeServicesTest : TestCase() {
val (exitCode, outputJarPath) = compileFile("stringTo.kt", outputJarName)
assertEquals(ExitCode.OK, exitCode)
assertCompileFails(
repl, """
import example.dependency.*
""".trimIndent()
)
assertEvalUnit(
repl, """
@file:DependsOn("$outputJarPath")
@@ -412,6 +418,17 @@ private fun JvmTestRepl.compileAndEval(codeLine: SourceCode): Pair<ResultWithDia
return compRes to evalRes?.valueOrNull().get()
}
private fun assertCompileFails(
repl: JvmTestRepl,
@Suppress("SameParameterValue")
line: String
) {
val compiledSnippet =
checkCompile(repl, line)
TestCase.assertNull(compiledSnippet)
}
private fun assertEvalUnit(
repl: JvmTestRepl,
@Suppress("SameParameterValue")