mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 15:53:46 +00:00
Don't initialize const properties in constructor
#KT-9532 Fixed
This commit is contained in:
committed by
Michael Bogdanov
parent
7d7d37719b
commit
3452fc8d02
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user