Search for JvmName also among use-site targeted annotations

#KT-9699 Fixed
This commit is contained in:
Alexander Udalov
2015-10-23 16:20:13 +03:00
parent ae4c7b5a61
commit 1517a099d0
3 changed files with 36 additions and 4 deletions
@@ -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"
}
@@ -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");
@@ -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