Generate 'DefaultImpls' for jvm 8 target only within compiler option

This commit is contained in:
Michael Bogdanov
2016-09-12 12:05:45 +03:00
parent ca41f01468
commit dd4d5e3aa1
15 changed files with 145 additions and 26 deletions
@@ -0,0 +1,24 @@
// JVM_TARGET: 1.8
// WITH_REFLECT
// KOTLIN_CONFIGURATION_FLAGS: +JVM.INTERFACE_COMPATIBILITY
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
}