JVM_IR. Don't copy synthetic method for property annotations if @JvmStatic presented
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
// !LANGUAGE: +UseGetterNameForPropertyAnnotationsMethodOnJvm
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
package test
|
||||
|
||||
import java.lang.reflect.Modifier
|
||||
import kotlin.test.*
|
||||
|
||||
class WithCompanionJvmStatic {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val property: Int
|
||||
get() = 42
|
||||
}
|
||||
}
|
||||
|
||||
interface InterfaceWithCompanionJvmStatic {
|
||||
|
||||
fun defaultImplsTrigger() = 123
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val property: Int
|
||||
get() = 42
|
||||
}
|
||||
}
|
||||
|
||||
fun check(clazz: Class<*>, expected: Boolean = true) {
|
||||
for (method in clazz.getDeclaredMethods()) {
|
||||
if (method.getName() == "getProperty\$annotations") {
|
||||
if (!expected) {
|
||||
fail("Synthetic method for annotated property found, but not expected: $method")
|
||||
}
|
||||
assertTrue(method.isSynthetic())
|
||||
assertTrue(Modifier.isStatic(method.modifiers))
|
||||
assertTrue(Modifier.isPublic(method.modifiers))
|
||||
val str = method.declaredAnnotations.single().toString()
|
||||
assertTrue("@kotlin.jvm.JvmStatic\\(\\)".toRegex().matches(str), str)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (expected) {
|
||||
fail("Synthetic method for annotated property expected, but not found")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check(Class.forName("test.WithCompanionJvmStatic"), expected = false)
|
||||
check(Class.forName("test.WithCompanionJvmStatic\$Companion"))
|
||||
|
||||
check(Class.forName("test.InterfaceWithCompanionJvmStatic"), expected = false)
|
||||
check(Class.forName("test.InterfaceWithCompanionJvmStatic\$DefaultImpls"), expected = false)
|
||||
check(Class.forName("test.InterfaceWithCompanionJvmStatic\$Companion"))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user