diff --git a/.idea/artifacts/KotlinPlugin.xml b/.idea/artifacts/KotlinPlugin.xml
index f798dab16d7..f6d23649e60 100644
--- a/.idea/artifacts/KotlinPlugin.xml
+++ b/.idea/artifacts/KotlinPlugin.xml
@@ -53,6 +53,10 @@
+
+
+
+
diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
index a86cb615fc0..2cddd7705c7 100644
--- a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
+++ b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.decompiler.IdeaLogger;
import org.jetbrains.kotlin.backend.common.output.OutputFile;
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
+import org.jetbrains.kotlin.backend.jvm.JvmBackendFacade;
import org.jetbrains.kotlin.codegen.ClassBuilderFactories;
import org.jetbrains.kotlin.codegen.CompilationErrorHandler;
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade;
@@ -132,7 +133,7 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
configuration.put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.JVM_1_8);
}
- return getBytecodeForFile(ktFile, configuration);
+ return getBytecodeForFile(ktFile, configuration, ir.isSelected());
}
@Override
@@ -181,6 +182,7 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
private final JCheckBox enableAssertions;
private final JButton decompile;
private final JCheckBox jvm8Target;
+ private final JCheckBox ir;
public KotlinBytecodeToolWindow(Project project, ToolWindow toolWindow) {
super(new BorderLayout());
@@ -220,9 +222,11 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
enableOptimization = new JCheckBox("Optimization", true);
enableAssertions = new JCheckBox("Assertions", true);
jvm8Target = new JCheckBox("JVM 8 target", false);
+ ir = new JCheckBox("IR", true);
optionPanel.add(enableInline);
optionPanel.add(enableOptimization);
optionPanel.add(enableAssertions);
+ optionPanel.add(ir);
optionPanel.add(jvm8Target);
new InfinitePeriodicalTask(UPDATE_DELAY, Alarm.ThreadToUse.SWING_THREAD, this, new Computable() {
@@ -237,10 +241,10 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
// public for tests
@NotNull
- public static String getBytecodeForFile(@NotNull KtFile ktFile, @NotNull CompilerConfiguration configuration) {
+ public static String getBytecodeForFile(@NotNull KtFile ktFile, @NotNull CompilerConfiguration configuration, boolean newIRGenerator) {
GenerationState state;
try {
- state = compileSingleFile(ktFile, configuration);
+ state = compileSingleFile(ktFile, configuration, newIRGenerator);
}
catch (ProcessCanceledException e) {
throw e;
@@ -278,7 +282,11 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
}
@NotNull
- public static GenerationState compileSingleFile(@NotNull final KtFile ktFile, @NotNull CompilerConfiguration configuration) {
+ public static GenerationState compileSingleFile(
+ @NotNull final KtFile ktFile,
+ @NotNull CompilerConfiguration configuration,
+ boolean newIRGenerator
+ ) {
ResolutionFacade resolutionFacade = ResolutionUtils.getResolutionFacade(ktFile);
BindingContext bindingContextForFile = resolutionFacade.analyzeFullyAndGetResult(Collections.singletonList(ktFile)).getBindingContext();
@@ -316,7 +324,11 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
ktFile.getProject(), ClassBuilderFactories.TEST, resolutionFacade.getModuleDescriptor(), bindingContext, toProcess,
configuration, generateClassFilter
);
- KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
+ if (newIRGenerator) {
+ JvmBackendFacade.INSTANCE.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
+ } else {
+ KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
+ }
return state;
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt
index d4122f69d7a..b02382d55da 100644
--- a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinDecompilerServiceImpl.kt
@@ -72,7 +72,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
}
fun bytecodeMapForSourceFile(file: KtFile): Map ByteArray> {
- val generationState = KotlinBytecodeToolWindow.compileSingleFile(file, CompilerConfiguration.EMPTY)
+ val generationState = KotlinBytecodeToolWindow.compileSingleFile(file, CompilerConfiguration.EMPTY, false)
val bytecodeMap = hashMapOf ByteArray>()
generationState.factory.asList().filter { FileUtilRt.extensionEquals(it.relativePath, "class") }.forEach {
diff --git a/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt b/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt
index d0dd589ea30..9103472e9f8 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/internal/AbstractBytecodeToolWindowTest.kt
@@ -44,7 +44,7 @@ abstract class AbstractBytecodeToolWindowTest: KotlinLightCodeInsightFixtureTest
if (InTextDirectivesUtils.getPrefixedBoolean(mainFileText, "// INLINE:") == false) {
configuration.put(CommonConfigurationKeys.DISABLE_INLINE, true)
}
- val bytecodes = KotlinBytecodeToolWindow.getBytecodeForFile(file, configuration)
+ val bytecodes = KotlinBytecodeToolWindow.getBytecodeForFile(file, configuration, false)
assert(bytecodes.contains("// ================")) {
"The header \"// ================\" is missing.\n This means that there is an exception failed during compilation:\n$bytecodes"
}