Initial support of @JvmDefault

This commit is contained in:
Mikhael Bogdanov
2018-02-20 18:02:54 +01:00
parent e885195ee1
commit fe45eb2a81
50 changed files with 322 additions and 256 deletions
@@ -1,5 +1,5 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_REFLECT
annotation class Property(val value: String)
@@ -7,6 +7,7 @@ annotation class Accessor(val value: String)
interface Z {
@Property("OK")
@kotlin.annotations.JvmDefault
val z: String
@Accessor("OK")
get() = "OK"
@@ -16,7 +17,7 @@ interface Z {
class Test : Z
fun box() : String {
val value = (Z::z.annotations.single() as Property).value
val value = Z::z.annotations.filterIsInstance<Property>().single().value
if (value != "OK") return value
return (Z::z.getter.annotations.single() as Accessor).value
}
@@ -1,24 +0,0 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS, +JVM.INTERFACE_COMPATIBILITY
// WITH_REFLECT
annotation class Property(val value: String)
annotation class Accessor(val value: String)
interface Z {
@Property("OK")
val z: String
@Accessor("OK")
get() = "OK"
}
class Test : Z
fun box() : String {
val value = (Z::z.annotations.single() as Property).value
if (value != "OK") return value
val forName = Class.forName("Z\$DefaultImpls")
val annotation = forName.getDeclaredMethod("z\$annotations").getAnnotation(Property::class.java)
return annotation.value
}