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.
This commit is contained in:
pyos
2021-06-30 21:26:26 +02:00
committed by Alexander Udalov
parent 6897e89bbc
commit a7c13db575
3 changed files with 5 additions and 2 deletions
@@ -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,
)
}
}
@@ -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 }
@@ -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)