JVM_IR: Remove buggy special case accessor code from JvmStaticAnnotationLowering
General purpose accessors in SyntheticAnnotationLowering are sufficient.
This commit is contained in:
+8
-21
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.util.*
|
|||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
|
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
|
||||||
|
|
||||||
@@ -62,28 +63,14 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) :
|
|||||||
it is IrClass && it.isCompanion
|
it is IrClass && it.isCompanion
|
||||||
} as IrClass?
|
} as IrClass?
|
||||||
|
|
||||||
companion?.declarations?.filter(::isJvmStaticFunction)?.forEach {
|
companion?.declarations?.filter(::isJvmStaticFunction)?.forEach { declaration ->
|
||||||
val jvmStaticFunction = it as IrSimpleFunction
|
val jvmStaticFunction = declaration as IrSimpleFunction
|
||||||
val newName = Name.identifier(context.methodSignatureMapper.mapFunctionName(jvmStaticFunction))
|
val newName = Name.identifier(context.methodSignatureMapper.mapFunctionName(jvmStaticFunction))
|
||||||
if (!jvmStaticFunction.visibility.isPublicAPI) {
|
val proxy = createProxy(
|
||||||
// TODO: Synthetic accessor creation logic should be supported in SyntheticAccessorLowering in the future.
|
jvmStaticFunction, irClass, companion, newName, jvmStaticFunction.visibility,
|
||||||
val accessorName = Name.identifier("access\$$newName")
|
isSynthetic = false
|
||||||
val accessor = createProxy(
|
)
|
||||||
jvmStaticFunction, companion, companion, accessorName, Visibilities.PUBLIC,
|
irClass.addMember(proxy)
|
||||||
isSynthetic = true
|
|
||||||
)
|
|
||||||
companion.addMember(accessor)
|
|
||||||
val proxy = createProxy(
|
|
||||||
accessor, irClass, companion, newName, jvmStaticFunction.visibility, isSynthetic = false
|
|
||||||
)
|
|
||||||
irClass.addMember(proxy)
|
|
||||||
} else {
|
|
||||||
val proxy = createProxy(
|
|
||||||
jvmStaticFunction, irClass, companion, newName, jvmStaticFunction.visibility,
|
|
||||||
isSynthetic = false
|
|
||||||
)
|
|
||||||
irClass.addMember(proxy)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// FILE: tt.kt
|
||||||
|
package tt
|
||||||
|
|
||||||
|
class CA {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
@JvmName("uhoh")
|
||||||
|
internal fun f(): String = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: qq.kt
|
||||||
|
|
||||||
|
package qq
|
||||||
|
import tt.CA
|
||||||
|
|
||||||
|
fun box() = CA.f()
|
||||||
+5
@@ -15938,6 +15938,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmNameForAccessor.kt")
|
||||||
|
public void testJvmNameForAccessor() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/jvmNameForAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt21246.kt")
|
@TestMetadata("kt21246.kt")
|
||||||
public void testKt21246() throws Exception {
|
public void testKt21246() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
||||||
|
|||||||
+5
@@ -15938,6 +15938,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmNameForAccessor.kt")
|
||||||
|
public void testJvmNameForAccessor() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/jvmNameForAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt21246.kt")
|
@TestMetadata("kt21246.kt")
|
||||||
public void testKt21246() throws Exception {
|
public void testKt21246() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
||||||
|
|||||||
+5
@@ -14813,6 +14813,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmNameForAccessor.kt")
|
||||||
|
public void testJvmNameForAccessor() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/jvmNameForAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt21246.kt")
|
@TestMetadata("kt21246.kt")
|
||||||
public void testKt21246() throws Exception {
|
public void testKt21246() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
||||||
|
|||||||
+5
@@ -14813,6 +14813,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/interfaceCompanion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmNameForAccessor.kt")
|
||||||
|
public void testJvmNameForAccessor() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmStatic/jvmNameForAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt21246.kt")
|
@TestMetadata("kt21246.kt")
|
||||||
public void testKt21246() throws Exception {
|
public void testKt21246() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
runTest("compiler/testData/codegen/box/jvmStatic/kt21246.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user