diff --git a/compiler/testData/codegen/boxWithStdlib/jvmName/propertyAccessorsUseSite.kt b/compiler/testData/codegen/boxWithStdlib/jvmName/propertyAccessorsUseSite.kt new file mode 100644 index 00000000000..218495d8283 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/jvmName/propertyAccessorsUseSite.kt @@ -0,0 +1,25 @@ +import kotlin.test.assertEquals + +class TestIt { + @get:JvmName("getIsFries") + @set:JvmName("setIsFries") + var isFries: Boolean = true + + @get:JvmName("getIsUpdateable") + @set:JvmName("setIsUpdateable") + var isUpdateable: Boolean by Delegate +} + +object Delegate { + operator fun getValue(thiz: Any?, metadata: Any?) = true + operator fun setValue(thiz: Any?, metadata: Any?, value: Boolean) {} +} + +fun box(): String { + assertEquals( + listOf("getIsFries", "getIsUpdateable", "setIsFries", "setIsUpdateable"), + TestIt::class.java.declaredMethods.map { it.name }.sorted() + ) + + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 22d5842cb74..dd56c2dd071 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2131,6 +2131,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("propertyAccessorsUseSite.kt") + public void testPropertyAccessorsUseSite() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/jvmName/propertyAccessorsUseSite.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("propertyName.kt") public void testPropertyName() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/jvmName/propertyName.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index 3ae4b3cff4f..f12823affc6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotated; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor; import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor; @@ -595,11 +596,11 @@ public class DescriptorUtils { @Nullable public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) { - AnnotationDescriptor jvmNameAnnotation = annotations.findAnnotation(JVM_NAME); - if (jvmNameAnnotation == null) { - jvmNameAnnotation = annotations.findAnnotation(PLATFORM_NAME); + AnnotationWithTarget jvmName = Annotations.Companion.findAnyAnnotation(annotations, JVM_NAME); + if (jvmName == null) { + jvmName = Annotations.Companion.findAnyAnnotation(annotations, PLATFORM_NAME); } - return jvmNameAnnotation; + return jvmName == null ? null : jvmName.getAnnotation(); } @Nullable