Don't initialize const properties in constructor

#KT-9532 Fixed
This commit is contained in:
Michael Bogdanov
2015-10-17 12:32:41 +03:00
committed by Michael Bogdanov
parent 7d7d37719b
commit 3452fc8d02
10 changed files with 123 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(KotlinInterface.FOO_INT)
public String test() throws NoSuchMethodException {
return KotlinInterface.FOO_STRING +
JavaClass.class.getMethod("test").getAnnotation(Foo.class).value();
}
}

View File

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