diff --git a/compiler/backend/backend.iml b/compiler/backend/backend.iml
index 2934ca7b771..0a5e4d1a810 100644
--- a/compiler/backend/backend.iml
+++ b/compiler/backend/backend.iml
@@ -12,7 +12,5 @@
-
-
\ No newline at end of file
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.kt
new file mode 100644
index 00000000000..c217dce50d6
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.codegen
+
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
+import org.jetbrains.kotlin.descriptors.ClassDescriptor
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
+
+enum class OwnerKind {
+ PACKAGE,
+ IMPLEMENTATION,
+ DEFAULT_IMPLS;
+
+ companion object {
+ fun getMemberOwnerKind(descriptor: DeclarationDescriptor): OwnerKind = when (descriptor) {
+ is FileClassDescriptor, is PackageFragmentDescriptor -> OwnerKind.PACKAGE
+ is ClassDescriptor -> OwnerKind.IMPLEMENTATION
+ else -> throw AssertionError("Unexpected declaration container: $this")
+ }
+ }
+}
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/descriptors/FileClassDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/descriptors/FileClassDescriptor.kt
new file mode 100644
index 00000000000..1a156ac4598
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/descriptors/FileClassDescriptor.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2010-2017 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.codegen.descriptors
+
+import org.jetbrains.kotlin.descriptors.ClassDescriptor
+
+interface FileClassDescriptor : ClassDescriptor
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/defaultMethodUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/defaultMethodUtil.kt
index 90dc02ad5b1..46326c066a1 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/defaultMethodUtil.kt
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/defaultMethodUtil.kt
@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.codegen.inline
-import org.jetbrains.kotlin.backend.jvm.codegen.getMemberOwnerKind
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.OwnerKind
import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.DEFAULT_LAMBDA_FAKE_CALL
@@ -48,12 +47,9 @@ private data class Condition(
fun extractDefaultLambdaOffsetAndDescriptor(jvmSignature: JvmMethodSignature, functionDescriptor: FunctionDescriptor): Map {
val valueParameters = jvmSignature.valueParameters
val containingDeclaration = functionDescriptor.containingDeclaration
- val kind = containingDeclaration.getMemberOwnerKind().let {
- if (DescriptorUtils.isInterface(containingDeclaration)) {
- OwnerKind.DEFAULT_IMPLS
- }
- else it
- }
+ val kind =
+ if (DescriptorUtils.isInterface(containingDeclaration)) OwnerKind.DEFAULT_IMPLS
+ else OwnerKind.getMemberOwnerKind(containingDeclaration)
val parameterOffsets = parameterOffsets(AsmUtil.isStaticMethod(kind, functionDescriptor), valueParameters)
val valueParameterOffset = valueParameters.takeWhile { it.kind != JvmMethodParameterKind.VALUE }.size
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt
index b73fcc3be8c..c44ec856178 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen.state
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ModificationTracker
import com.intellij.psi.PsiElement
-import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.`when`.MappingsClassesForWhenByEnum
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
@@ -56,6 +55,7 @@ class GenerationState @JvmOverloads constructor(
val files: List,
val configuration: CompilerConfiguration,
val generateDeclaredClassFilter: GenerateClassFilter = GenerationState.GenerateClassFilter.GENERATE_ALL,
+ val codegenFactory: CodegenFactory = DefaultCodegenFactory,
// For incremental compilation
val targetId: TargetId? = null,
moduleName: String? = configuration.get(CommonConfigurationKeys.MODULE_NAME),
@@ -64,7 +64,6 @@ class GenerationState @JvmOverloads constructor(
// TODO: get rid of it with the proper module infrastructure
val outDirectory: File? = null,
private val onIndependentPartCompilationEnd: GenerationStateEventCallback = GenerationStateEventCallback.DO_NOTHING,
- val codegenFactory: CodegenFactory = if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory else DefaultCodegenFactory,
wantsDiagnostics: Boolean = true
) {
abstract class GenerateClassFilter {
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java
index 8b15f916330..7a7d49563cd 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.codegen.signature.AsmTypeFactory;
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
import org.jetbrains.kotlin.descriptors.*;
+import org.jetbrains.kotlin.descriptors.IrBuiltinsPackageFragmentDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableAccessorDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
@@ -42,7 +43,6 @@ import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
-import org.jetbrains.kotlin.ir.descriptors.IrBuiltinsPackageFragmentDescriptor;
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature;
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.SpecialSignatureInfo;
import org.jetbrains.kotlin.load.java.JvmAbi;
@@ -236,6 +236,7 @@ public class KotlinTypeMapper {
if (facadeFqName != null) return facadeFqName;
}
+ // TODO: drop this usage and move IrBuiltinsPackageFragmentDescriptor to IR modules; it shouldn't be used here
if (descriptor.getContainingDeclaration() instanceof IrBuiltinsPackageFragmentDescriptor) {
return descriptor.getContainingDeclaration().getName().asString();
}
diff --git a/compiler/cli/cli.iml b/compiler/cli/cli.iml
index 1e543e4aaeb..7cdbb89daca 100644
--- a/compiler/cli/cli.iml
+++ b/compiler/cli/cli.iml
@@ -24,5 +24,6 @@
+
\ No newline at end of file
diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
index 3475464f772..4eab7713cd7 100644
--- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
+++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.kt
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.asJava.FilteredJvmDiagnostics
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
+import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.checkKotlinPackageUsage
@@ -39,10 +40,7 @@ import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil
import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.jvm.config.*
-import org.jetbrains.kotlin.codegen.ClassBuilderFactories
-import org.jetbrains.kotlin.codegen.CompilationErrorHandler
-import org.jetbrains.kotlin.codegen.GeneratedClassLoader
-import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
+import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
import org.jetbrains.kotlin.config.CommonConfigurationKeys
@@ -438,6 +436,7 @@ object KotlinToJVMBytecodeCompiler {
sourceFiles,
configuration,
GenerationState.GenerateClassFilter.GENERATE_ALL,
+ if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory else DefaultCodegenFactory,
module?.let(::TargetId),
module?.let(Module::getModuleName),
module?.let { File(it.getOutputDirectory()) },
diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.java b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/IrBuiltinsPackageFragmentDescriptor.kt
similarity index 78%
rename from compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.java
rename to compiler/frontend/src/org/jetbrains/kotlin/descriptors/IrBuiltinsPackageFragmentDescriptor.kt
index 34857b8bb93..9ea46807b35 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/OwnerKind.java
+++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/IrBuiltinsPackageFragmentDescriptor.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2015 JetBrains s.r.o.
+ * Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,12 +14,6 @@
* limitations under the License.
*/
-package org.jetbrains.kotlin.codegen;
+package org.jetbrains.kotlin.descriptors
-public enum OwnerKind {
- PACKAGE,
-
- IMPLEMENTATION,
-
- DEFAULT_IMPLS
-}
+interface IrBuiltinsPackageFragmentDescriptor : PackageFragmentDescriptor
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
index a7d36d64f85..d3d027e8978 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.descriptors.JvmDescriptorWithExtraFlags
-import org.jetbrains.kotlin.backend.jvm.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.MemberCodegen.badDescriptor
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
@@ -244,7 +243,7 @@ private fun MemberDescriptor.calcModalityFlag(): Int {
return flags
}
-val MemberDescriptor.effectiveModality: Modality
+private val MemberDescriptor.effectiveModality: Modality
get() {
if (this is ClassDescriptor && kind == ClassKind.ENUM_CLASS) {
if (JvmCodegenUtil.hasAbstractMembers(this)) {
@@ -260,21 +259,11 @@ val MemberDescriptor.effectiveModality: Modality
return modality
}
-val DeclarationDescriptorWithSource.psiElement: PsiElement?
+private val DeclarationDescriptorWithSource.psiElement: PsiElement?
get() = (source as? PsiSourceElement)?.psi
-val IrField.OtherOrigin: JvmDeclarationOrigin
+private val IrField.OtherOrigin: JvmDeclarationOrigin
get() = OtherOrigin(descriptor.psiElement, this.descriptor)
-val IrFunction.OtherOrigin: JvmDeclarationOrigin
+internal val IrFunction.OtherOrigin: JvmDeclarationOrigin
get() = OtherOrigin(descriptor.psiElement, this.descriptor)
-
-fun DeclarationDescriptor.getMemberOwnerKind(): OwnerKind = when (this) {
- is FileClassDescriptor,
- is PackageFragmentDescriptor ->
- OwnerKind.PACKAGE
- is ClassDescriptor ->
- OwnerKind.IMPLEMENTATION
- else ->
- throw AssertionError("Unexpected declaration container: $this")
-}
\ No newline at end of file
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
index 9c3a8aaf02e..2cf6da59821 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt
@@ -53,7 +53,8 @@ class FunctionCodegen(val irFunction: IrFunction, val classCodegen: ClassCodegen
private fun doGenerate() {
val signature = classCodegen.typeMapper.mapSignatureWithGeneric(descriptor, OwnerKind.IMPLEMENTATION)
- val isStatic = isStaticMethod(classCodegen.descriptor.getMemberOwnerKind(), descriptor) || DescriptorUtils.isStaticDeclaration(descriptor)
+ val isStatic = isStaticMethod(OwnerKind.getMemberOwnerKind(classCodegen.descriptor), descriptor) ||
+ DescriptorUtils.isStaticDeclaration(descriptor)
val frameMap = createFrameMapWithReceivers(classCodegen.state, descriptor, signature, isStatic)
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptor.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptorImpl.kt
similarity index 95%
rename from compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptor.kt
rename to compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptorImpl.kt
index 36bd241d3ec..7f013aefdc0 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptor.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/FileClassDescriptorImpl.kt
@@ -16,13 +16,12 @@
package org.jetbrains.kotlin.backend.jvm.descriptors
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.KotlinType
-interface FileClassDescriptor : ClassDescriptor
-
class FileClassDescriptorImpl(
name: Name,
containingDeclaration: PackageFragmentDescriptor,
@@ -39,4 +38,4 @@ class FileClassDescriptorImpl(
}
override fun isExternal() = false
-}
\ No newline at end of file
+}
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SpecialDescriptorsFactory.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SpecialDescriptorsFactory.kt
index b750b6d8ad6..8088f527660 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SpecialDescriptorsFactory.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SpecialDescriptorsFactory.kt
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.backend.jvm.descriptors
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
index 33200c66126..a9005ddb274 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt
@@ -17,13 +17,12 @@
package org.jetbrains.kotlin.backend.jvm.lower
import com.intellij.psi.PsiElement
+import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.backend.common.bridges.Bridge
import org.jetbrains.kotlin.backend.common.bridges.findInterfaceImplementation
import org.jetbrains.kotlin.backend.common.bridges.generateBridgesForFunctionDescriptor
-import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.backend.jvm.JvmLoweredStatementOrigin
import org.jetbrains.kotlin.backend.jvm.descriptors.DefaultImplsClassDescriptor
-import org.jetbrains.kotlin.backend.jvm.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.backend.jvm.descriptors.JvmFunctionDescriptorImpl
import org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityAccessFlag
import org.jetbrains.kotlin.codegen.AsmUtil.isAbstractMethod
@@ -33,6 +32,7 @@ import org.jetbrains.kotlin.codegen.FunctionCodegen.isThereOverriddenInKotlinCla
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.codegen.JvmCodegenUtil.getDirectMember
import org.jetbrains.kotlin.codegen.OwnerKind
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.*
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ClassLowerWithContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ClassLowerWithContext.kt
index 8a3e7acf18f..3c6fef21fad 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ClassLowerWithContext.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ClassLowerWithContext.kt
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.backend.jvm.lower
import org.jetbrains.kotlin.backend.common.FileLoweringPass
-import org.jetbrains.kotlin.backend.jvm.descriptors.FileClassDescriptor
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrClass
diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
index 01f4630d716..3f071131d6e 100644
--- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
+++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.backend.jvm.lower
import org.jetbrains.kotlin.backend.common.FileLoweringPass
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
-import org.jetbrains.kotlin.backend.jvm.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.backend.jvm.intrinsics.receiverAndArgs
import org.jetbrains.kotlin.codegen.AccessorForCallableDescriptor
import org.jetbrains.kotlin.codegen.AccessorForPropertyDescriptor
@@ -26,6 +25,7 @@ import org.jetbrains.kotlin.codegen.JvmCodegenUtil
import org.jetbrains.kotlin.codegen.OwnerKind
import org.jetbrains.kotlin.codegen.context.ClassContext
import org.jetbrains.kotlin.codegen.context.CodegenContext
+import org.jetbrains.kotlin.codegen.descriptors.FileClassDescriptor
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.*
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptorImpl.kt
similarity index 84%
rename from compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptor.kt
rename to compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptorImpl.kt
index adb55a2701c..55c2f2535a5 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptor.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltinsPackageFragmentDescriptorImpl.kt
@@ -16,14 +16,16 @@
package org.jetbrains.kotlin.ir.descriptors
-import org.jetbrains.kotlin.descriptors.*
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
+import org.jetbrains.kotlin.descriptors.ModuleDescriptor
+import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.Annotations
+import org.jetbrains.kotlin.descriptors.IrBuiltinsPackageFragmentDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.MemberScope
-interface IrBuiltinsPackageFragmentDescriptor : PackageFragmentDescriptor
-
class IrBuiltinsPackageFragmentDescriptorImpl(
val containingModule: ModuleDescriptor,
override val fqName: FqName
diff --git a/compiler/tests-common/org/jetbrains/kotlin/codegen/GenerationUtils.kt b/compiler/tests-common/org/jetbrains/kotlin/codegen/GenerationUtils.kt
index caa4d3bd455..40cf31ab685 100644
--- a/compiler/tests-common/org/jetbrains/kotlin/codegen/GenerationUtils.kt
+++ b/compiler/tests-common/org/jetbrains/kotlin/codegen/GenerationUtils.kt
@@ -17,11 +17,13 @@
package org.jetbrains.kotlin.codegen
import com.intellij.psi.search.GlobalSearchScope
+import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAllTo
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.CompilerConfiguration
+import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.AnalyzingUtils
@@ -64,7 +66,8 @@ object GenerationUtils {
val state = GenerationState(
files.first().project, classBuilderFactory, analysisResult.moduleDescriptor, analysisResult.bindingContext,
- files, configuration
+ files, configuration,
+ codegenFactory = if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory else DefaultCodegenFactory
)
if (analysisResult.shouldGenerateCode) {
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION)
diff --git a/compiler/tests-common/tests-common.iml b/compiler/tests-common/tests-common.iml
index 125931ef603..346329a992f 100644
--- a/compiler/tests-common/tests-common.iml
+++ b/compiler/tests-common/tests-common.iml
@@ -30,5 +30,6 @@
+
\ No newline at end of file
diff --git a/idea/idea.iml b/idea/idea.iml
index c4ea1c6ef1d..3c7bcad1f8a 100644
--- a/idea/idea.iml
+++ b/idea/idea.iml
@@ -67,5 +67,6 @@
+
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
index f15fb534e7b..0a66ac7e492 100644
--- a/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
+++ b/idea/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.java
@@ -37,8 +37,10 @@ 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.JvmIrCodegenFactory;
import org.jetbrains.kotlin.codegen.ClassBuilderFactories;
import org.jetbrains.kotlin.codegen.CompilationErrorHandler;
+import org.jetbrains.kotlin.codegen.DefaultCodegenFactory;
import org.jetbrains.kotlin.codegen.KotlinCodegenFacade;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.config.*;
@@ -325,7 +327,8 @@ public class KotlinBytecodeToolWindow extends JPanel implements Disposable {
GenerationState state = new GenerationState(
ktFile.getProject(), ClassBuilderFactories.TEST, resolutionFacade.getModuleDescriptor(), bindingContext, toProcess,
- configuration, generateClassFilter
+ configuration, generateClassFilter,
+ configuration.getBoolean(JVMConfigurationKeys.IR) ? JvmIrCodegenFactory.INSTANCE : DefaultCodegenFactory.INSTANCE
);
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);