Use JVM name of getter in synthetic method for property annotations
#KT-31352 In Progress
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ class PropertiesLowering(
|
||||
private val originOfSyntheticMethodForAnnotations: IrDeclarationOrigin? = null,
|
||||
private val skipExternalProperties: Boolean = false,
|
||||
private val generateAnnotationFields: Boolean = false,
|
||||
private val computeSyntheticMethodName: ((Name) -> String)? = null
|
||||
private val computeSyntheticMethodName: ((IrProperty) -> String)? = null
|
||||
) : IrElementTransformerVoid(), FileLoweringPass {
|
||||
override fun lower(irFile: IrFile) {
|
||||
irFile.accept(this, null)
|
||||
@@ -63,7 +63,7 @@ class PropertiesLowering(
|
||||
if (declaration.annotations.isNotEmpty() && originOfSyntheticMethodForAnnotations != null
|
||||
&& computeSyntheticMethodName != null
|
||||
) {
|
||||
val methodName = computeSyntheticMethodName.invoke(declaration.name) // Workaround KT-4113
|
||||
val methodName = computeSyntheticMethodName.invoke(declaration) // Workaround KT-4113
|
||||
add(createSyntheticMethodForAnnotations(declaration, originOfSyntheticMethodForAnnotations, methodName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.backend.common.lower.*
|
||||
import org.jetbrains.kotlin.backend.common.lower.loops.forLoopsPhase
|
||||
import org.jetbrains.kotlin.backend.common.phaser.*
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.*
|
||||
import org.jetbrains.kotlin.codegen.OwnerKind
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
@@ -67,10 +68,13 @@ private val lateinitPhase = makeIrFilePhase(
|
||||
description = "Insert checks for lateinit field references"
|
||||
)
|
||||
|
||||
private val propertiesPhase = makeIrFilePhase<CommonBackendContext>(
|
||||
private val propertiesPhase = makeIrFilePhase<JvmBackendContext>(
|
||||
{ context ->
|
||||
PropertiesLowering(context, JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_ANNOTATIONS) { propertyName ->
|
||||
JvmAbi.getSyntheticMethodNameForAnnotatedProperty(propertyName)
|
||||
PropertiesLowering(context, JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_ANNOTATIONS) { property ->
|
||||
val getterName = property.getter?.let { getter ->
|
||||
context.typeMapper.mapFunctionName(getter, OwnerKind.IMPLEMENTATION)
|
||||
} ?: JvmAbi.getterName(property.name.asString())
|
||||
JvmAbi.getSyntheticMethodNameForAnnotatedProperty(getterName)
|
||||
}
|
||||
},
|
||||
name = "Properties",
|
||||
|
||||
Reference in New Issue
Block a user