From a7c13db575090644d6075b5c5c696eb67bc74a95 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 30 Jun 2021 21:26:26 +0200 Subject: [PATCH] JVM_IR: add `$delegate` methods to a few exclusion lists 1. they don't need type annotations; 2. internal ones include the module name before the `$delegate` part, so further mangling is redundant 3. they don't need multifile facade bridges. Unlike `$annotations`, delegated properties don't appear in interfaces, so exclusions in InterfaceLowering would be redundant. --- .../jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt | 5 +++-- .../kotlin/backend/jvm/codegen/MethodSignatureMapper.kt | 1 + .../kotlin/backend/jvm/lower/GenerateMultifileFacades.kt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) 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 37634c94e5e..9633f8c1ddf 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 @@ -135,8 +135,6 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg irFunction.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS -> false irFunction is IrConstructor && irFunction.parentAsClass.shouldNotGenerateConstructorParameterAnnotations() -> - // Not generating parameter annotations for default stubs fixes KT-7892, though - // this certainly looks like a workaround for a javac bug. false else -> true @@ -310,6 +308,8 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg companion object { internal val methodOriginsWithoutAnnotations = setOf( + // Not generating parameter annotations for default stubs fixes KT-7892, though + // this certainly looks like a workaround for a javac bug. IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR, IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER, @@ -319,6 +319,7 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg JvmLoweredDeclarationOrigin.ABSTRACT_BRIDGE_STUB, JvmLoweredDeclarationOrigin.TO_ARRAY, IrDeclarationOrigin.IR_BUILTINS_STUB, + IrDeclarationOrigin.PROPERTY_DELEGATE, ) } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index b459e4d843d..55ff1ee20c7 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -132,6 +132,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { if (visibility == DescriptorVisibilities.INTERNAL && origin != JvmLoweredDeclarationOrigin.STATIC_INLINE_CLASS_CONSTRUCTOR && origin != JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS && + origin != IrDeclarationOrigin.PROPERTY_DELEGATE && !isPublishedApi() ) { return originalFunction.takeIf { it != this } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt index e2d5cd2d1e4..ead1bb7c7ad 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt @@ -239,6 +239,7 @@ private fun IrSimpleFunction.createMultifileDelegateIfNeeded( name == StaticInitializersLowering.clinitName || origin == JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR || origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA || + origin == IrDeclarationOrigin.PROPERTY_DELEGATE || // $annotations methods in the facade are only needed for const properties. (origin == JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS && (metadata as? MetadataSource.Property)?.isConst != true)