Refactor Main-Class computation in CLI for JVM with .jar outputs
Compute FQ name of the main class right after running the analysis and before invoking codegen. This is needed because MainFunctionDetector depends on BindingContext, and JVM IR needs to clear BindingContext as soon as it's not necessary to reduce peak memory usage, thus breaking any usages of data from it after the codegen. Also refactor and use the extracted, but not properly reused previously, copy of findMainClass in findMainClass.kt. Note that this replaces NPE in KT-42868 with an UOE.
This commit is contained in:
+3
-2
@@ -10,7 +10,6 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.roots.libraries.ui.OrderRoot
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
@@ -32,6 +31,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.resolve.getLanguageVersionSettings
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.KotlinBaseTest.TestFile
|
||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||
@@ -198,7 +198,8 @@ class DebuggerTestCompilerFacility(
|
||||
|
||||
state.factory.writeAllTo(classesDir)
|
||||
|
||||
return findMainClass(state, files)?.asString() ?: error("Cannot find main class name")
|
||||
return findMainClass(bindingContext, resolutionFacade.getLanguageVersionSettings(), files)?.asString()
|
||||
?: error("Cannot find main class name")
|
||||
}
|
||||
|
||||
private fun getClasspath(module: Module): List<String> {
|
||||
|
||||
Reference in New Issue
Block a user