Use type from compile time value for binary expression
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import java.lang.annotation.Retention
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
||||
Retention(RetentionPolicy.RUNTIME)
|
||||
annotation class Ann(
|
||||
val p1: Int,
|
||||
val p2: Short,
|
||||
val p3: Byte,
|
||||
val p4: Int,
|
||||
val p5: Int,
|
||||
val p6: Int
|
||||
)
|
||||
|
||||
val prop1: Int = 1 or 1
|
||||
val prop2: Short = 1 and 1
|
||||
val prop3: Byte = 1 xor 1
|
||||
val prop4: Int = 1 shl 1
|
||||
val prop5: Int = 1 shr 1
|
||||
val prop6: Int = 1 ushr 1
|
||||
|
||||
Ann(1 or 1, 1 and 1, 1 xor 1, 1 shl 1, 1 shr 1, 1 ushr 1) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val annotation = javaClass<MyClass>().getAnnotation(javaClass<Ann>())!!
|
||||
if (annotation.p1 != prop1) return "fail 1, expected = ${prop1}, actual = ${annotation.p1}"
|
||||
if (annotation.p2 != prop2) return "fail 2, expected = ${prop2}, actual = ${annotation.p2}"
|
||||
if (annotation.p3 != prop3) return "fail 3, expected = ${prop3}, actual = ${annotation.p3}"
|
||||
if (annotation.p4 != prop4) return "fail 4, expected = ${prop4}, actual = ${annotation.p4}"
|
||||
if (annotation.p5 != prop5) return "fail 5, expected = ${prop5}, actual = ${annotation.p5}"
|
||||
if (annotation.p6 != prop6) return "fail 6, expected = ${prop6}, actual = ${annotation.p6}"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user