Test for obsolete KT-3698: Static fields of primitive types and String must be compile-time constants

#KT-3698 Obsolete
This commit is contained in:
Michael Bogdanov
2015-05-15 15:30:09 +03:00
parent 4e1a90ee61
commit 576ead2afe
3 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class JavaClass {
@Retention(RetentionPolicy.RUNTIME)
@interface Foo {
int value();
}
@Foo(KotlinClass.FOO_INT)
public String test() throws NoSuchMethodException {
return KotlinClass.FOO_STRING +
JavaClass.class.getMethod("test").getAnnotation(Foo.class).value();
}
}

View File

@@ -0,0 +1,11 @@
class KotlinClass {
companion object {
val FOO_INT: Int = 10
val FOO_STRING: String = "OK"
}
}
fun box(): String {
val test = JavaClass().test()
return if (test == "OK10") "OK" else "fail : $test"
}