Load unsigned constants from class file with the use of expected type

This commit is contained in:
Mikhail Zarechenskiy
2018-07-09 13:28:10 +03:00
parent 9b6e8fa5d1
commit 14b8ff7d71
6 changed files with 45 additions and 3 deletions
@@ -5,17 +5,27 @@
@kotlin.annotation.Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION)
annotation class Anno(val u: UInt)
const val ONE_UINT = 1u
object ForTest {
@Anno(0u)
fun f(a: @Anno(43u) String) {}
@Anno(ONE_UINT)
fun g(b: @Anno(ONE_UINT) String) {}
}
// FILE: B.kt
fun box(): String {
val result = (ForTest::f.annotations.first() as Anno).u // force annotation deserialization
if (result != 0u) return "Fail"
val fResult = (ForTest::f.annotations.first() as Anno).u // force annotation deserialization
if (fResult != 0u) return "Fail"
val gResult = (ForTest::g.annotations.first() as Anno).u
if (gResult != 1u) return "Fail"
if (ONE_UINT != 1u) return "Fail"
return "OK"
}