mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 08:31:35 +00:00
Add some tests on Java property references
This commit is contained in:
3
compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java
vendored
Normal file
3
compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
public class J {
|
||||
static String x;
|
||||
}
|
||||
12
compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt
vendored
Normal file
12
compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
val f = J::x
|
||||
assertEquals("x", f.name)
|
||||
|
||||
f.set("OK")
|
||||
assertEquals("OK", J.x)
|
||||
assertEquals("OK", f.getter())
|
||||
|
||||
return f.get()
|
||||
}
|
||||
3
compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java
vendored
Normal file
3
compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
public class J {
|
||||
public String foo = "";
|
||||
}
|
||||
23
compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt
vendored
Normal file
23
compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import kotlin.test.*
|
||||
|
||||
class K : J() {
|
||||
fun getFoo(): String = "K"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val j = J()
|
||||
val x = J::foo
|
||||
x.set(j, "J")
|
||||
assertEquals("J", x.get(j))
|
||||
|
||||
val k = K()
|
||||
val y = K::foo
|
||||
y.set(k, "K")
|
||||
assertEquals("K", y.get(k))
|
||||
assertEquals("K", x.get(k))
|
||||
|
||||
val z = K::getFoo
|
||||
assertEquals("K", z.invoke(k))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user