diff --git a/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java new file mode 100644 index 00000000000..00317c601f4 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java @@ -0,0 +1,3 @@ +public class J { + static String x; +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt new file mode 100644 index 00000000000..869e71619f0 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt @@ -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() +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java new file mode 100644 index 00000000000..c081e6d25cf --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java @@ -0,0 +1,3 @@ +public class J { + public String foo = ""; +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt new file mode 100644 index 00000000000..d78c60c8661 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt @@ -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" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 590575d2c01..d3e078cf43e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -285,12 +285,24 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege doTestWithJava(fileName); } + @TestMetadata("javaStaticField") + public void testJavaStaticField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/javaStaticField/"); + doTestWithJava(fileName); + } + @TestMetadata("kotlinPropertyInheritedInJava") public void testKotlinPropertyInheritedInJava() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/"); doTestWithJava(fileName); } + @TestMetadata("noConflictOnKotlinGetterAndJavaField") + public void testNoConflictOnKotlinGetterAndJavaField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/"); + doTestWithJava(fileName); + } + } @TestMetadata("compiler/testData/codegen/boxWithJava/secondaryConstructors")