diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt index 57f33887209..382ecc0df30 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt @@ -447,7 +447,7 @@ private fun buildFunctionDeclaration(irFunction: IrFunction, origin: IrDeclarati IrSimpleFunctionSymbolImpl(descriptor), name, irFunction.visibility, - Modality.FINAL, + if (irFunction.modality === Modality.ABSTRACT) Modality.OPEN else irFunction.modality, irFunction.returnType, irFunction.isInline, false, 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 5f566c20919..8cde1a46879 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 @@ -89,7 +89,7 @@ open class ClassCodegen protected constructor( signature.superclassName, signature.interfaces.toTypedArray() ) - AnnotationCodegen.forClass(visitor.visitor, this, typeMapper).genAnnotations(descriptor, null) + AnnotationCodegen.forClass(visitor.visitor, this, context.state).genAnnotations(descriptor, null) /* TODO: Temporary workaround: ClassBuilder needs a pathless name. */ val shortName = File(fileEntry.name).name visitor.visitSource(shortName, null) 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 dae003c1bca..e727dc2fc40 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 @@ -306,9 +306,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass { when (typeSafeBarrierDescription) { BuiltinMethodsWithSpecialGenericSignature.TypeSafeBarrierDescription.MAP_GET_OR_DEFAULT -> irGet( bridgeDescriptor.valueParameters[1].type.toIrType()!!, - IrVariableSymbolImpl( - bridgeDescriptor.valueParameters[1] - ) + bridgeFunction.valueParameters[1].symbol ) BuiltinMethodsWithSpecialGenericSignature.TypeSafeBarrierDescription.NULL -> irNull() BuiltinMethodsWithSpecialGenericSignature.TypeSafeBarrierDescription.INDEX -> IrConstImpl.int( diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt index 39a501b075e..c81f4bdfb3f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.backend.common.ClassLoweringPass -import org.jetbrains.kotlin.backend.common.makePhase import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor import org.jetbrains.kotlin.backend.common.ir.copyParameterDeclarationsFrom import org.jetbrains.kotlin.backend.common.lower.createIrBuilder @@ -98,6 +97,7 @@ class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementTra name, Visibilities.PUBLIC, inheritedFun.modality, + inheritedFun.returnType, isInline = inheritedFun.isInline, isExternal = false, isTailrec = false, @@ -105,7 +105,6 @@ class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementTra ).apply { descriptor.bind(this) parent = inheritedFun.parent - returnType = inheritedFun.returnType overriddenSymbols.addAll(inheritedFun.overriddenSymbols) copyParameterDeclarationsFrom(inheritedFun) } @@ -137,16 +136,4 @@ class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementTra private fun IrSimpleFunction.isDefinitelyNotDefaultImplsMethod() = resolveFakeOverride()?.let { origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB } == true || hasAnnotation(PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME) - - private fun IrClass.getNonPrivateInterfaceMethods(): List> { - return declarations.filterIsInstance().mapNotNull { function -> - val resolved = function.resolveFakeOverride() - resolved?.takeIf { - resolved !== function && // TODO: take a better look - (resolved.parent as? IrClass)?.isInterface == true && - !Visibilities.isPrivate(resolved.visibility) && - resolved.visibility != Visibilities.INVISIBLE_FAKE - }?.let { Pair(resolved, function) } - } - } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt index fe8d0776879..9d8ff272518 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.backend.common.ir.copyTo import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom import org.jetbrains.kotlin.backend.common.lower.DECLARATION_ORIGIN_FUNCTION_FOR_DEFAULT_PARAMETER import org.jetbrains.kotlin.backend.common.lower.InitializersLowering.Companion.clinitName -import org.jetbrains.kotlin.backend.common.makePhase import org.jetbrains.kotlin.backend.common.lower.VariableRemapper import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.descriptors.* @@ -37,9 +36,7 @@ class InterfaceLowering(val context: JvmBackendContext) : IrElementTransformerVo val members = defaultImplsIrClass.declarations irClass.declarations.filterIsInstance().forEach { - if (it.origin == DECLARATION_ORIGIN_FUNCTION_FOR_DEFAULT_PARAMETER) { - members.add(it) //just copy $default to DefaultImpls - } else if (it is IrSimpleFunction && it.modality != Modality.ABSTRACT && it.origin != IrDeclarationOrigin.FAKE_OVERRIDE) { + if (it is IrSimpleFunction && it.modality != Modality.ABSTRACT && it.origin != IrDeclarationOrigin.FAKE_OVERRIDE) { val element = context.declarationFactory.getDefaultImplsFunction(it) members.add(element) element.body = it.body @@ -79,11 +76,11 @@ internal fun createStaticFunctionWithReceivers( name, oldFunction.visibility, Modality.FINAL, + oldFunction.returnType, isInline = false, isExternal = false, isTailrec = false, isSuspend = false ).apply { descriptor.bind(this) parent = irParent - returnType = oldFunction.returnType copyTypeParametersFrom(oldFunction)