Add mode to run kapt with JVM IR, use in tests

Currently JVM IR is not supported in kapt, so almost all tests are
failing, and thus are muted with IGNORE_BACKEND.

 #KT-49682
This commit is contained in:
Alexander Udalov
2021-12-08 23:05:43 +01:00
parent d089d27bef
commit ebb9659e03
107 changed files with 251 additions and 98 deletions
@@ -85,6 +85,11 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> IR =
CompilerConfigurationKey.create("IR");
// Temporary option to make it possible to test kapt with JVM IR. As soon as all tests start to pass, it can be removed,
// and the backend (old or IR) will be deduced from the compiler arguments provided by the user.
public static final CompilerConfigurationKey<Boolean> USE_KAPT_WITH_JVM_IR =
CompilerConfigurationKey.create("Enable JVM IR for kapt");
public static final CompilerConfigurationKey<Boolean> USE_PSI_CLASS_FILES_READING =
CompilerConfigurationKey.create("use a slower (PSI-based) class files reading implementation");
@@ -185,9 +185,9 @@ object GenerationUtils {
analysisResult: AnalysisResult,
configureGenerationState: GenerationState.Builder.() -> Unit = {},
): GenerationState {
/* Currently Kapt3 only works with the old JVM backend, so disable IR for everything except actual bytecode generation. */
val isIrBackend =
classBuilderFactory.classBuilderMode == ClassBuilderMode.FULL && configuration.getBoolean(JVMConfigurationKeys.IR)
(classBuilderFactory.classBuilderMode == ClassBuilderMode.FULL && configuration.getBoolean(JVMConfigurationKeys.IR)) ||
configuration.getBoolean(JVMConfigurationKeys.USE_KAPT_WITH_JVM_IR)
val generationState = GenerationState.Builder(
project, classBuilderFactory, analysisResult.moduleDescriptor, analysisResult.bindingContext,
files, configuration