diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 5d14517f5aa..8f560a2c571 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -40225,24 +40225,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("fieldAccessors.kt") - public void testFieldAccessors() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -40255,58 +40237,238 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("jvmStaticFieldInObject.kt") - public void testJvmStaticFieldInObject() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt"); - } - - @Test - @TestMetadata("jvmStaticFunction.kt") - public void testJvmStaticFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt"); - } - - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt"); + } } - @Test - @TestMetadata("suspendFunction.kt") - public void testSuspendFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt"); + } } } } diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt deleted file mode 100644 index a7898a1a443..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt +++ /dev/null @@ -1,29 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT -import kotlin.test.assertEquals - -inline class Z(val x: Int) - -class Outer(val z1: Z) { - inner class Inner(val z2: Z) { - val test = "$z1 $z2" - } -} - -inline class InlineOuter(val z1: Z) { - @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") - inner class Inner(val z2: Z) { - val test = "$z1 $z2" - } -} - -fun box(): String { - assertEquals(Z(1), ::Outer.call(Z(1)).z1) - assertEquals("Z(x=1) Z(x=2)", Outer::Inner.call(Outer(Z(1)), Z(2)).test) - assertEquals("Z(x=1) Z(x=3)", Outer(Z(1))::Inner.call(Z(3)).test) - assertEquals("Z(x=1) Z(x=2)", InlineOuter::Inner.call(InlineOuter(Z(1)), Z(2)).test) - assertEquals("Z(x=1) Z(x=3)", InlineOuter(Z(1))::Inner.call(Z(3)).test) - - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt deleted file mode 100644 index eee6b146996..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt +++ /dev/null @@ -1,37 +0,0 @@ -// TARGET_BACKEND: JVM -// WITH_REFLECT - -import kotlin.reflect.KCallable -import kotlin.reflect.jvm.isAccessible -import kotlin.test.assertEquals - -inline class S(val value: String) { - operator fun plus(other: S): S = S(this.value + other.value) -} - -class C { - private var member: S = S("") - - fun unboundRef() = C::member.apply { isAccessible = true } - fun boundRef() = this::member.apply { isAccessible = true } -} - -private var topLevel: S = S("") - -fun box(): String { - val c = C() - assertEquals(Unit, c.unboundRef().setter.call(c, S("ab"))) - assertEquals(S("ab"), c.unboundRef().call(c)) - assertEquals(S("ab"), c.unboundRef().getter.call(c)) - - assertEquals(Unit, c.boundRef().setter.call(S("cd"))) - assertEquals(S("cd"), c.boundRef().call()) - assertEquals(S("cd"), c.boundRef().getter.call()) - - val topLevel = ::topLevel.apply { isAccessible = true } - assertEquals(Unit, topLevel.setter.call(S("ef"))) - assertEquals(S("ef"), topLevel.call()) - assertEquals(S("ef"), topLevel.getter.call()) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt deleted file mode 100644 index 6b991ae5d15..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt +++ /dev/null @@ -1,32 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT - -import kotlin.test.assertEquals - -inline class S(val value: String) { - operator fun plus(other: S): S = S(this.value + other.value) -} - -class C { - fun member(x: S, y: String): S = x + S(y) -} - -fun topLevel(x: String, y: S): S = S(x) + y - -fun S.extension(y: S): S = this + y - -fun S.extension2(): String = value - -fun box(): String { - assertEquals(S("ab"), C::member.call(C(), S("a"), "b")) - assertEquals(S("cd"), ::topLevel.call("c", S("d"))) - assertEquals(S("gh"), S::extension.call(S("g"), S("h"))) - assertEquals("_", S::extension2.call(S("_"))) - - assertEquals(S("ij"), C()::member.call(S("i"), "j")) - assertEquals(S("mn"), S("m")::extension.call(S("n"))) - assertEquals("_", S("_")::extension2.call()) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt index 9337937e657..e1537746d69 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt @@ -4,6 +4,7 @@ import kotlin.reflect.KCallable import kotlin.test.assertEquals +import kotlin.test.assertFailsWith inline class Z(val x: Int) { constructor(a: Int, b: Int) : this(a + b) @@ -13,36 +14,48 @@ inline class L(val x: Long) { constructor(a: Long, b: Long) : this(a + b) } -inline class S(val x: String) { +inline class S1(val x: String) { constructor(a: String, b: String) : this(a + b) } +inline class S2(val x: String?) { + constructor(a: String?, b: String?) : this(a!! + b!!) +} + inline class A(val x: Any) { constructor(a: String, b: String) : this(a + b) } inline class Z2(val z: Z) +inline class Z3(val z: Z?) fun box(): String { - val ctorZ1: (Int) -> Z = ::Z - val ctorZ2: (Int, Int) -> Z = ::Z + val ctorZ1_1: (Int) -> Z = ::Z + val ctorZ1_2: (Int, Int) -> Z = ::Z val ctorL1: (Long) -> L = ::L val ctorL2: (Long, Long) -> L = ::L - val ctorS1: (String) -> S = ::S - val ctorS2: (String, String) -> S = ::S + val ctorS1_1: (String) -> S1 = ::S1 + val ctorS1_2: (String, String) -> S1 = ::S1 + val ctorS2_1: (String) -> S2 = ::S2 + val ctorS2_2: (String, String) -> S2 = ::S2 val ctorA1: (Any) -> A = ::A val ctorA2: (String, String) -> A = ::A - assertEquals(Z(42), (ctorZ1 as KCallable).call(42)) - assertEquals(Z(123), (ctorZ2 as KCallable).call(100, 23)) + assertEquals(Z(42), (ctorZ1_1 as KCallable).call(42)) + assertEquals(Z(123), (ctorZ1_2 as KCallable).call(100, 23)) assertEquals(L(1L), (ctorL1 as KCallable).call(1L)) assertEquals(L(123L), (ctorL2 as KCallable).call(100L, 23L)) - assertEquals(S("abc"), (ctorS1 as KCallable).call("abc")) - assertEquals(S("abc"), (ctorS2 as KCallable).call("ab", "c")) + assertEquals(S1("abc"), (ctorS1_1 as KCallable).call("abc")) + assertEquals(S1("abc"), (ctorS1_2 as KCallable).call("ab", "c")) + assertEquals(S2("abc"), (ctorS2_1 as KCallable).call("abc")) + assertEquals(S2("abc"), (ctorS2_2 as KCallable).call("ab", "c")) assertEquals(A("abc"), (ctorA1 as KCallable).call("abc")) assertEquals(A("abc"), (ctorA2 as KCallable).call("a", "bc")) assertEquals(Z2(Z(42)), ::Z2.call(Z(42))) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Z3(Z(42)), ::Z3.call(Z(42))) + } return "OK" } diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt index 2fbe8ace968..0f64c635eaf 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt @@ -10,8 +10,10 @@ inline class Z2(internal val x: Z) inline class L(internal val x: Long) inline class L2(internal val x: L) -inline class A(internal val x: Any?) -inline class A2(internal val x: A) +inline class A1(internal val x: Any?) +inline class A1_2(internal val x: A1) +inline class A2(internal val x: Any) +inline class A2_2(internal val x: A2) fun box(): String { assertEquals(42, Z::x.call(Z(42))) @@ -20,10 +22,12 @@ fun box(): String { assertEquals(1234L, L::x.call(L(1234L))) assertEquals(1234L, L(1234L)::x.call()) - assertEquals("abc", A::x.call(A("abc"))) - assertEquals("abc", A("abc")::x.call()) - assertEquals(null, A::x.call(A(null))) - assertEquals(null, A(null)::x.call()) + assertEquals("abc", A1::x.call(A1("abc"))) + assertEquals("abc", A1("abc")::x.call()) + assertEquals(null, A1::x.call(A1(null))) + assertEquals(null, A1(null)::x.call()) + assertEquals("abc", A2::x.call(A2("abc"))) + assertEquals("abc", A2("abc")::x.call()) assertEquals(Z(42), Z2::x.call(Z2(Z(42)))) assertEquals(Z(42), Z2(Z(42))::x.call()) @@ -31,10 +35,12 @@ fun box(): String { assertEquals(L(1234L), L2::x.call(L2(L(1234L)))) assertEquals(L(1234L), L2(L(1234L))::x.call()) - assertEquals(A("abc"), A2::x.call(A2(A("abc")))) - assertEquals(A("abc"), A2(A("abc"))::x.call()) - assertEquals(A(null), A2::x.call(A2(A(null)))) - assertEquals(A(null), A2(A(null))::x.call()) + assertEquals(A1("abc"), A1_2::x.call(A1_2(A1("abc")))) + assertEquals(A1("abc"), A1_2(A1("abc"))::x.call()) + assertEquals(A1(null), A1_2::x.call(A1_2(A1(null)))) + assertEquals(A1(null), A1_2(A1(null))::x.call()) + assertEquals(A2("abc"), A2_2::x.call(A2_2(A2("abc")))) + assertEquals(A2("abc"), A2_2(A2("abc"))::x.call()) return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt deleted file mode 100644 index 626eabedccf..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt +++ /dev/null @@ -1,33 +0,0 @@ -// TARGET_BACKEND: JVM -// JVM_TARGET: 1.8 -// WITH_REFLECT - -import kotlin.reflect.KMutableProperty1 -import kotlin.reflect.jvm.isAccessible -import kotlin.test.assertEquals - -inline class S(val value: String) { - operator fun plus(other: S): S = S(this.value + other.value) -} - -object C { - @JvmStatic - private var p: S = S("") - - fun boundRef() = this::p.apply { isAccessible = true } -} - -fun box(): String { - val unboundRef = C::class.members.single { it.name == "p" } as KMutableProperty1 - unboundRef.isAccessible = true - assertEquals(Unit, unboundRef.setter.call(C, S("ab"))) - assertEquals(S("ab"), unboundRef.call(C)) - assertEquals(S("ab"), unboundRef.getter.call(C)) - - val boundRef = C.boundRef() - assertEquals(Unit, boundRef.setter.call(S("cd"))) - assertEquals(S("cd"), boundRef.call()) - assertEquals(S("cd"), boundRef.getter.call()) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt new file mode 100644 index 00000000000..0e5a6e3a9fb --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt @@ -0,0 +1,50 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals + +inline class S(val x: String) + +class Outer(val z1: S, val z2: S?) { + inner class Inner(val z3: S, val z4: S?) { + val test = "$z1 $z2 $z3 $z4" + } +} + +inline class InlineNonNullOuter(val z1: S) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: S, val z3: S?) { + val test = "$z1 $z2 $z3" + } +} + +inline class InlineNullableOuter(val z1: S?) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: S, val z3: S?) { + val test = "$z1 $z2 $z3" + } +} + +fun box(): String { + val z1 = S("1") + val z2 = S("2") + val z3 = S("3") + val z4 = S("4") + + val outer = ::Outer.call(z1, z2) + assertEquals(z1, outer.z1) + assertEquals(z2, outer.z2) + + assertEquals("S(x=1) S(x=2) S(x=3) S(x=4)", Outer::Inner.call(outer, z3, z4).test) + assertEquals("S(x=1) S(x=2) S(x=2) S(x=4)", outer::Inner.call(z2, z4).test) + + val inlineNonNullOuter = InlineNonNullOuter(z1) + assertEquals("S(x=1) S(x=2) S(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test) + assertEquals("S(x=1) S(x=2) S(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test) + + val inlineNullableOuter = InlineNullableOuter(z1) + assertEquals("S(x=1) S(x=2) S(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test) + assertEquals("S(x=1) S(x=2) S(x=2)", inlineNullableOuter::Inner.call(z2, z2).test) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt new file mode 100644 index 00000000000..f773e0c5787 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt @@ -0,0 +1,53 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals + +inline class S(val value: String) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + private var nonNullMember: S = S("") + private var nullableMember: S? = S("") + + fun nonNullUnboundRef() = C::nonNullMember.apply { isAccessible = true } + fun nonNullBoundRef() = this::nonNullMember.apply { isAccessible = true } + fun nullableUnboundRef() = C::nullableMember.apply { isAccessible = true } + fun nullableBoundRef() = this::nullableMember.apply { isAccessible = true } +} + +private var nonNullTopLevel: S = S("") +private var nullableTopLevel: S? = S("") + +fun box(): String { + val c = C() + assertEquals(Unit, c.nonNullUnboundRef().setter.call(c, S("ab"))) + assertEquals(S("ab"), c.nonNullUnboundRef().call(c)) + assertEquals(S("ab"), c.nonNullUnboundRef().getter.call(c)) + + assertEquals(Unit, c.nonNullBoundRef().setter.call(S("cd"))) + assertEquals(S("cd"), c.nonNullBoundRef().call()) + assertEquals(S("cd"), c.nonNullBoundRef().getter.call()) + + assertEquals(Unit, c.nullableUnboundRef().setter.call(c, S("ab"))) + assertEquals(S("ab"), c.nullableUnboundRef().call(c)) + assertEquals(S("ab"), c.nullableUnboundRef().getter.call(c)) + + assertEquals(Unit, c.nullableBoundRef().setter.call(S("cd"))) + assertEquals(S("cd"), c.nullableBoundRef().call()) + assertEquals(S("cd"), c.nullableBoundRef().getter.call()) + + val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true } + assertEquals(Unit, nonNullTopLevel.setter.call(S("ef"))) + assertEquals(S("ef"), nonNullTopLevel.call()) + assertEquals(S("ef"), nonNullTopLevel.getter.call()) + + val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true } + assertEquals(Unit, nullableTopLevel.setter.call(S("ef"))) + assertEquals(S("ef"), nullableTopLevel.call()) + assertEquals(S("ef"), nullableTopLevel.getter.call()) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt new file mode 100644 index 00000000000..76bb17937e9 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt @@ -0,0 +1,46 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + fun member(x: S, y: String, z: S?): S = x + S(y) + z!! +} + +fun topLevel(x: String, y: S, z: S?): S = S(x) + y + z!! + +fun S.extension1(y: S, z: S?): S = this + y + z!! + +fun S?.extension2(y: S, z: S?) = this!! + y + z!! + +fun S.extension3(): String = value + +fun S?.extension4(): String = this!!.value + +fun box(): String { + assertEquals(S("abc"), C::member.call(C(), S("a"), "b", S("c"))) + assertEquals(S("def"), ::topLevel.call("d", S("e"), S("f"))) + assertEquals(S("ghi"), S::extension1.call(S("g"), S("h"), S("i"))) + assertEquals(S("jkl"), S::extension2.call(S("j"), S("k"), S("l"))) + assertEquals("_", S::extension3.call(S("_"))) + assertEquals("_", S?::extension4.call(S("_"))) + + assertEquals(S("mno"), C()::member.call(S("m"), "n", S("o"))) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("pqr"), S("p")::extension1.call(S("q"), "r")) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("stu"), S("s")::extension2.call(S("t"), "u")) + } + assertEquals("_", S("_")::extension3.call()) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("_", S("_")::extension4.call(S("_"))) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt new file mode 100644 index 00000000000..ebe59282c29 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt @@ -0,0 +1,48 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty1 +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals + +inline class S(val value: String) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +object C { + @JvmStatic + private var p1: S = S("") + + @JvmStatic + private var p2: S? = S("") + + fun nonNullBoundRef() = this::p1.apply { isAccessible = true } + fun nullableBoundRef() = this::p2.apply { isAccessible = true } +} + +fun box(): String { + val nonNullUnboundRef = C::class.members.single { it.name == "p1" } as KMutableProperty1 + nonNullUnboundRef.isAccessible = true + assertEquals(Unit, nonNullUnboundRef.setter.call(C, S("ab"))) + assertEquals(S("ab"), nonNullUnboundRef.call(C)) + assertEquals(S("ab"), nonNullUnboundRef.getter.call(C)) + + val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1 + nullableUnboundRef.isAccessible = true + assertEquals(Unit, nullableUnboundRef.setter.call(C, S("ab"))) + assertEquals(S("ab"), nullableUnboundRef.call(C)) + assertEquals(S("ab"), nullableUnboundRef.getter.call(C)) + + val nonNullBoundRef = C.nonNullBoundRef() + assertEquals(Unit, nonNullBoundRef.setter.call(S("cd"))) + assertEquals(S("cd"), nonNullBoundRef.call()) + assertEquals(S("cd"), nonNullBoundRef.getter.call()) + + val nullableBoundRef = C.nullableBoundRef() + assertEquals(Unit, nullableBoundRef.setter.call(S("cd"))) + assertEquals(S("cd"), nullableBoundRef.call()) + assertEquals(S("cd"), nullableBoundRef.getter.call()) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt similarity index 58% rename from compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt rename to compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt index 3f86a4a2292..0a4a6a476eb 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt @@ -11,25 +11,25 @@ inline class S(val value: String) { object C { @JvmStatic - fun foo(x: S, y: String): S = x + S(y) + fun foo(x: S, y: String, z: S?): S = x + S(y) + z!! } interface I { companion object { @JvmStatic - fun bar(x: String, y: S): S = S(x) + y + fun bar(x: String, y: S, z: S?): S = S(x) + y + z!! } } fun box(): String { - assertEquals(S("ab"), C::foo.call(S("a"), "b")) - assertEquals(S("cd"), (I)::bar.call("c", S("d"))) + assertEquals(S("abc"), C::foo.call(S("a"), "b", S("c"))) + assertEquals(S("def"), (I)::bar.call("d", S("e"), S("f"))) val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*> - assertEquals(S("ef"), unboundFoo.call(C, S("e"), "f")) + assertEquals(S("ghi"), unboundFoo.call(C, S("g"), "h", S("i"))) val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*> - assertEquals(S("gh"), unboundBar.call(I, "g", S("h"))) + assertEquals(S("jkl"), unboundBar.call(I, "j", S("k"), S("l"))) return "OK" } diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt new file mode 100644 index 00000000000..e52e9863a8a --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals + +inline class S(val x: String) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class Z(val x: Int) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val plus = S("+") + val aster = S("*") + + assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) + assertEquals("42-+*", S("42")::test.call("-", plus, aster)) + + assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) + assertEquals("42-+*", Z(42)::test.call("-", plus, aster)) + + assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) + assertEquals("42-+*", A("42")::test.call("-", plus, aster)) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt new file mode 100644 index 00000000000..7112a9485d8 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt @@ -0,0 +1,112 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals + +var global = S("") + +inline class S(val x: String) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class Z(val x: Int) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class A(val x: Any) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +fun box(): String { + global = S("") + assertEquals(S("42"), S::nonNullTest.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.call()) + assertEquals(S("42"), S::nonNullTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.getter.call()) + S::nonNullTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nonNullTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertEquals(S("42"), S::nullableTest.call(S("42"))) + assertEquals(S("42"), S("42")::nullableTest.call()) + assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nullableTest.getter.call()) + S::nullableTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nullableTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertEquals(S("42"), Z::nonNullTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.call()) + assertEquals(S("42"), Z::nonNullTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nonNullTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertEquals(S("42"), Z::nullableTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nullableTest.call()) + assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nullableTest.getter.call()) + Z::nullableTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nullableTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertEquals(S("42"), A::nonNullTest.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.call()) + assertEquals(S("42"), A::nonNullTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.getter.call()) + A::nonNullTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nonNullTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + global = S("") + assertEquals(S("42"), A::nullableTest.call(A(42))) + assertEquals(S("42"), A(42)::nullableTest.call()) + assertEquals(S("42"), A::nullableTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nullableTest.getter.call()) + A::nullableTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nullableTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt new file mode 100644 index 00000000000..9e521513a03 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt @@ -0,0 +1,36 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals + +interface ITest { + fun test(a: String, b: S, c: S?): String +} + +inline class S(val x: String) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class Z(val x: Int) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val plus = S("+") + val aster = S("*") + + assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) + assertEquals("42-+*", S("42")::test.call("-", plus, aster)) + + assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) + assertEquals("42-+*", Z(42)::test.call("-", plus, aster)) + + assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) + assertEquals("42-+*", A("42")::test.call("-", plus, aster)) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt new file mode 100644 index 00000000000..ee1e1c3fbee --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt @@ -0,0 +1,117 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals + +var global = S("") + +interface ITest { + var nonNullTest: S + var nullableTest: S? +} + +inline class S(val x: String) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class Z(val x: Int) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class A(val x: Any) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +fun box(): String { + global = S("") + assertEquals(S("42"), S::nonNullTest.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.call()) + assertEquals(S("42"), S::nonNullTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.getter.call()) + S::nonNullTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nonNullTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertEquals(S("42"), S::nullableTest.call(S("42"))) + assertEquals(S("42"), S("42")::nullableTest.call()) + assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nullableTest.getter.call()) + S::nullableTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nullableTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertEquals(S("42"), Z::nonNullTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.call()) + assertEquals(S("42"), Z::nonNullTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nonNullTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertEquals(S("42"), Z::nullableTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nullableTest.call()) + assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nullableTest.getter.call()) + Z::nullableTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nullableTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertEquals(S("42"), A::nonNullTest.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.call()) + assertEquals(S("42"), A::nonNullTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.getter.call()) + A::nonNullTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nonNullTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + global = S("") + assertEquals(S("42"), A::nullableTest.call(A(42))) + assertEquals(S("42"), A(42)::nullableTest.call()) + assertEquals(S("42"), A::nullableTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nullableTest.getter.call()) + A::nullableTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nullableTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt new file mode 100644 index 00000000000..48215390f30 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt @@ -0,0 +1,116 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty2 +import kotlin.test.assertEquals + +inline class S(val value: String) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + var nonNullMember: S = S("") + var nullableMember: S? = S("") + + private var suffix = S("") + var S.nonNull_nonNullMemExt: S + get() = this + suffix + set(value) { suffix = this + value } + + var S.nonNull_nullableMemExt: S? + get() = this + suffix + set(value) { suffix = this + value!! } + + var S?.nullable_nonNullMemExt: S + get() = this!! + suffix + set(value) { suffix = this!! + value } + + var S?.nullable_nullableMemExt: S? + get() = this!! + suffix + set(value) { suffix = this!! + value!! } +} + +var nonNullTopLevel: S = S("") +var nullableTopLevel: S? = S("") + +private var suffix = S("") +var S.nonNull_nonNullExt: S + get() = this + suffix + set(value) { suffix = this + value } + +var S.nonNull_nullableExt: S? + get() = this + suffix + set(value) { suffix = this + value!! } + +var S?.nullable_nonNullExt: S + get() = this!! + suffix + set(value) { suffix = this!! + value } + +var S?.nullable_nullableExt: S? + get() = this!! + suffix + set(value) { suffix = this!! + value!! } + +fun box(): String { + val c = C() + assertEquals(Unit, C::nonNullMember.setter.call(c, S("ab"))) + assertEquals(S("ab"), C::nonNullMember.call(c)) + assertEquals(S("ab"), C::nonNullMember.getter.call(c)) + + assertEquals(Unit, c::nonNullMember.setter.call(S("cd"))) + assertEquals(S("cd"), c::nonNullMember.call()) + assertEquals(S("cd"), c::nonNullMember.getter.call()) + + assertEquals(Unit, C::nullableMember.setter.call(c, S("ab"))) + assertEquals(S("ab"), C::nullableMember.call(c)) + assertEquals(S("ab"), C::nullableMember.getter.call(c)) + + assertEquals(Unit, c::nullableMember.setter.call(S("cd"))) + assertEquals(S("cd"), c::nullableMember.call()) + assertEquals(S("cd"), c::nullableMember.getter.call()) + + val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2 + assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nonNull_nonNullMemExt.call(c, S("e"))) + assertEquals(S("ef"), nonNull_nonNullMemExt.getter.call(c, S("e"))) + + val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2 + assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nonNull_nullableMemExt.call(c, S("e"))) + assertEquals(S("ef"), nonNull_nullableMemExt.getter.call(c, S("e"))) + + val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2 + assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nullable_nonNullMemExt.call(c, S("e"))) + assertEquals(S("ef"), nullable_nonNullMemExt.getter.call(c, S("e"))) + + val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2 + assertEquals(Unit, nullable_nullableMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nullable_nullableMemExt.call(c, S("e"))) + assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e"))) + + assertEquals(Unit, ::nonNullTopLevel.setter.call(S("gh"))) + assertEquals(S("gh"), ::nonNullTopLevel.call()) + assertEquals(S("gh"), ::nonNullTopLevel.getter.call()) + + assertEquals(Unit, ::nullableTopLevel.setter.call(S("gh"))) + assertEquals(S("gh"), ::nullableTopLevel.call()) + assertEquals(S("gh"), ::nullableTopLevel.getter.call()) + + assertEquals(Unit, S::nonNull_nonNullExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S::nonNull_nonNullExt.call(S("i"))) + assertEquals(S("ij"), S::nonNull_nonNullExt.getter.call(S("i"))) + + assertEquals(Unit, S::nonNull_nullableExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S::nonNull_nullableExt.call(S("i"))) + assertEquals(S("ij"), S::nonNull_nullableExt.getter.call(S("i"))) + + assertEquals(Unit, S?::nullable_nonNullExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S?::nullable_nonNullExt.call(S("i"))) + assertEquals(S("ij"), S?::nullable_nonNullExt.getter.call(S("i"))) + + assertEquals(Unit, S?::nullable_nullableExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S?::nullable_nullableExt.call(S("i"))) + assertEquals(S("ij"), S?::nullable_nullableExt.getter.call(S("i"))) + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt new file mode 100644 index 00000000000..36e3ff057af --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt @@ -0,0 +1,61 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT +// WITH_COROUTINES + +import kotlin.coroutines.startCoroutine +import kotlin.reflect.full.callSuspend +import kotlin.test.assertEquals +import helpers.* + +inline class S(val value: String) + +class C { + private var value: S = S("") + + suspend fun nonNullConsume(z: S) { value = z } + suspend fun nonNullProduce(): S = value + suspend fun nullableConsume(z: S?) { value = z!! } + suspend fun nullableProduce(): S? = value + suspend fun nonNull_nonNullConsumeAndProduce(z: S): S = z + suspend fun nonNull_nullableConsumeAndProduce(z: S): S? = z + suspend fun nullable_nonNullConsumeAndProduce(z: S?): S = z!! + suspend fun nullable_nullableConsumeAndProduce(z: S?): S? = z +} + +private fun run0(f: suspend () -> String): String { + var result = "" + f.startCoroutine(handleResultContinuation { result = it }) + return result +} + +fun box(): String { + val c = C() + + run0 { + C::nonNullConsume.callSuspend(c, S("nonNull")) + C::nonNullProduce.callSuspend(c).value + }.let { assertEquals("nonNull", it) } + + run0 { + C::nullableConsume.callSuspend(c, S("nullable")) + C::nullableProduce.callSuspend(c)!!.value + }.let { assertEquals("nullable", it) } + + run0 { + C::nonNull_nonNullConsumeAndProduce.callSuspend(c, S("nonNull_nonNull")).value + }.let { assertEquals("nonNull_nonNull", it) } + + run0 { + C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value + }.let { assertEquals("nonNull_nullable", it) } + + run0 { + C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value + }.let { assertEquals("nullable_nonNull", it) } + + run0 { + C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value + }.let { assertEquals("nullable_nullable", it) } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt deleted file mode 100644 index f3aeb57cfcf..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt +++ /dev/null @@ -1,36 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT -import kotlin.test.assertEquals - -inline class Z(val x: Int) { - fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class L(val x: Long) { - fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class S(val x: String) { - fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class A(val x: Any) { - fun test(a: String, b: S) = "$x$a${b.x}" -} - -fun box(): String { - assertEquals("42-+", Z::test.call(Z(42), "-", S("+"))) - assertEquals("42-+", Z(42)::test.call("-", S("+"))) - - assertEquals("42-+", L::test.call(L(42L), "-", S("+"))) - assertEquals("42-+", L(42L)::test.call("-", S("+"))) - - assertEquals("42-+", S::test.call(S("42"), "-", S("+"))) - assertEquals("42-+", S("42")::test.call("-", S("+"))) - - assertEquals("42-+", A::test.call(A("42"), "-", S("+"))) - assertEquals("42-+", A("42")::test.call("-", S("+"))) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt deleted file mode 100644 index 9eee6b76be9..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt +++ /dev/null @@ -1,82 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT -import kotlin.test.assertEquals - -var global = S("") - -inline class Z(val x: Int) { - var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class L(val x: Long) { - var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class S(val x: String) { - var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class A(val x: Any) { - var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -fun box(): String { - global = S("") - assertEquals(S("42"), Z::test.call(Z(42))) - assertEquals(S("42"), Z(42)::test.call()) - assertEquals(S("42"), Z::test.getter.call(Z(42))) - assertEquals(S("42"), Z(42)::test.getter.call()) - Z::test.setter.call(Z(42), S("Z-")) - assertEquals(S("Z-42"), global) - Z(42)::test.setter.call(S("Z+")) - assertEquals(S("Z+42"), global) - - global = S("") - assertEquals(S("42"), L::test.call(L(42L))) - assertEquals(S("42"), L(42L)::test.call()) - assertEquals(S("42"), L::test.getter.call(L(42L))) - assertEquals(S("42"), L(42L)::test.getter.call()) - L::test.setter.call(L(42L), S("L-")) - assertEquals(S("L-42"), global) - L(42L)::test.setter.call(S("L+")) - assertEquals(S("L+42"), global) - - global = S("") - assertEquals(S("42"), S::test.call(S("42"))) - assertEquals(S("42"), S("42")::test.call()) - assertEquals(S("42"), S::test.getter.call(S("42"))) - assertEquals(S("42"), S("42")::test.getter.call()) - S::test.setter.call(S("42"), S("S-")) - assertEquals(S("S-42"), global) - S("42")::test.setter.call(S("S+")) - assertEquals(S("S+42"), global) - - global = S("") - assertEquals(S("42"), A::test.call(A(42))) - assertEquals(S("42"), A(42)::test.call()) - assertEquals(S("42"), A::test.getter.call(A(42))) - assertEquals(S("42"), A(42)::test.getter.call()) - A::test.setter.call(A(42), S("A-")) - assertEquals(S("A-42"), global) - A(42)::test.setter.call(S("A+")) - assertEquals(S("A+42"), global) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt new file mode 100644 index 00000000000..bd8cded0325 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt @@ -0,0 +1,63 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val x: String?) + +class Outer(val z1: S, val z2: S?) { + inner class Inner(val z3: S, val z4: S?) { + val test = "$z1 $z2 $z3 $z4" + } +} + +inline class InlineNonNullOuter(val z1: S) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: S, val z3: S?) { + val test = "$z1 $z2 $z3" + } +} + +inline class InlineNullableOuter(val z1: S?) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: S, val z3: S?) { + val test = "$z1 $z2 $z3" + } +} + +fun box(): String { + val z1 = S("1") + val z2 = S("2") + val z3 = S("3") + val z4 = S("4") + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + val outer = ::Outer.call(z1, z2) + assertEquals(z1, outer.z1) + assertEquals(z2, outer.z2) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("S(x=1) S(x=2) S(x=3) S(x=4)", Outer::Inner.call(outer, z3, z4).test) + assertEquals("S(x=1) S(x=2) S(x=2) S(x=4)", outer::Inner.call(z2, z4).test) + } + } + + val inlineNonNullOuter = InlineNonNullOuter(z1) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("S(x=1) S(x=2) S(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("S(x=1) S(x=2) S(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test) + } + + val inlineNullableOuter = InlineNullableOuter(z1) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("S(x=1) S(x=2) S(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("S(x=1) S(x=2) S(x=2)", inlineNullableOuter::Inner.call(z2, z2).test) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt new file mode 100644 index 00000000000..4c5563778b8 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt @@ -0,0 +1,60 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String?) { + operator fun plus(other: S): S = S(this.value!! + other.value!!) +} + +class C { + private var nonNullMember: S = S("") + private var nullableMember: S? = S("") + + fun nonNullUnboundRef() = C::nonNullMember.apply { isAccessible = true } + fun nonNullBoundRef() = this::nonNullMember.apply { isAccessible = true } + fun nullableUnboundRef() = C::nullableMember.apply { isAccessible = true } + fun nullableBoundRef() = this::nullableMember.apply { isAccessible = true } +} + +private var nonNullTopLevel: S = S("") +private var nullableTopLevel: S? = S("") + +fun box(): String { + val c = C() + assertEquals(Unit, c.nonNullUnboundRef().setter.call(c, S("ab"))) + assertEquals(S("ab"), c.nonNullUnboundRef().call(c)) + assertEquals(S("ab"), c.nonNullUnboundRef().getter.call(c)) + + assertEquals(Unit, c.nonNullBoundRef().setter.call(S("cd"))) + assertEquals(S("cd"), c.nonNullBoundRef().call()) + assertEquals(S("cd"), c.nonNullBoundRef().getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c.nullableUnboundRef().setter.call(c, S("ab"))) + assertEquals(S("ab"), c.nullableUnboundRef().call(c)) + assertEquals(S("ab"), c.nullableUnboundRef().getter.call(c)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c.nullableBoundRef().setter.call(S("cd"))) + assertEquals(S("cd"), c.nullableBoundRef().call()) + assertEquals(S("cd"), c.nullableBoundRef().getter.call()) + } + + val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true } + assertEquals(Unit, nonNullTopLevel.setter.call(S("ef"))) + assertEquals(S("ef"), nonNullTopLevel.call()) + assertEquals(S("ef"), nonNullTopLevel.getter.call()) + + val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableTopLevel.setter.call(S("ef"))) + assertEquals(S("ef"), nullableTopLevel.call()) + assertEquals(S("ef"), nullableTopLevel.getter.call()) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt new file mode 100644 index 00000000000..b4d6dc007f8 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt @@ -0,0 +1,58 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String?) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + fun member(x: S, y: String, z: S?): S = x + S(y) + z!! +} + +fun topLevel(x: String, y: S, z: S?): S = S(x) + y + z!! + +fun S.extension1(y: S, z: S?): S = this + y + z!! + +fun S?.extension2(y: S, z: S?) = this!! + y + z!! + +fun S.extension3(): String = value!! + +fun S?.extension4(): String = this!!.value!! + +fun box(): String { + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("abc"), C::member.call(C(), S("a"), "b", S("c"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("def"), ::topLevel.call("d", S("e"), S("f"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("ghi"), S::extension1.call(S("g"), S("h"), S("i"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("jkl"), S::extension2.call(S("j"), S("k"), S("l"))) + } + assertEquals("_", S::extension3.call(S("_"))) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("_", S?::extension4.call(S("_"))) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("mno"), C()::member.call(S("m"), "n", S("o"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("pqr"), S("p")::extension1.call(S("q"), "r")) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("stu"), S("s")::extension2.call(S("t"), "u")) + } + assertEquals("_", S("_")::extension3.call()) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("_", S("_")::extension4.call(S("_"))) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt new file mode 100644 index 00000000000..1e112d1c86f --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt @@ -0,0 +1,53 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty1 +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String?) { + operator fun plus(other: S): S = S(this.value!! + other.value!!) +} + +object C { + @JvmStatic + private var p1: S = S("") + + @JvmStatic + private var p2: S? = S("") + + fun nonNullBoundRef() = this::p1.apply { isAccessible = true } + fun nullableBoundRef() = this::p2.apply { isAccessible = true } +} + +fun box(): String { + val nonNullUnboundRef = C::class.members.single { it.name == "p1" } as KMutableProperty1 + nonNullUnboundRef.isAccessible = true + assertEquals(Unit, nonNullUnboundRef.setter.call(C, S("ab"))) + assertEquals(S("ab"), nonNullUnboundRef.call(C)) + assertEquals(S("ab"), nonNullUnboundRef.getter.call(C)) + + val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1 + nullableUnboundRef.isAccessible = true + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableUnboundRef.setter.call(C, S("ab"))) + assertEquals(S("ab"), nullableUnboundRef.call(C)) + assertEquals(S("ab"), nullableUnboundRef.getter.call(C)) + } + + val nonNullBoundRef = C.nonNullBoundRef() + assertEquals(Unit, nonNullBoundRef.setter.call(S("cd"))) + assertEquals(S("cd"), nonNullBoundRef.call()) + assertEquals(S("cd"), nonNullBoundRef.getter.call()) + + val nullableBoundRef = C.nullableBoundRef() + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableBoundRef.setter.call(S("cd"))) + assertEquals(S("cd"), nullableBoundRef.call()) + assertEquals(S("cd"), nullableBoundRef.getter.call()) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt new file mode 100644 index 00000000000..5d301d6f2b9 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt @@ -0,0 +1,44 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_REFLECT + +import kotlin.reflect.KFunction +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String?) { + operator fun plus(other: S): S = S(this.value!! + other.value!!) +} + +object C { + @JvmStatic + fun foo(x: S, y: String, z: S?): S = x + S(y) + z!! +} + +interface I { + companion object { + @JvmStatic + fun bar(x: String, y: S, z: S?): S = S(x) + y + z!! + } +} + +fun box(): String { + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("abc"), C::foo.call(S("a"), "b", S("c"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("def"), (I)::bar.call("d", S("e"), S("f"))) + } + + val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*> + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("ghi"), unboundFoo.call(C, S("g"), "h", S("i"))) + } + + val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*> + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("jkl"), unboundBar.call(I, "j", S("k"), S("l"))) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt new file mode 100644 index 00000000000..b031e690426 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt @@ -0,0 +1,45 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val x: String?) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class Z(val x: Int) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) { + fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val plus = S("+") + val aster = S("*") + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", S("42")::test.call("-", plus, aster)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", Z(42)::test.call("-", plus, aster)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", A("42")::test.call("-", plus, aster)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt new file mode 100644 index 00000000000..bc2b4a1ffa0 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt @@ -0,0 +1,149 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +var global = S("") + +inline class S(val x: String?) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class Z(val x: Int) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class A(val x: Any) { + var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +fun box(): String { + global = S("") + assertEquals(S("42"), S::nonNullTest.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.call()) + assertEquals(S("42"), S::nonNullTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.getter.call()) + S::nonNullTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nonNullTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S::nullableTest.call(S("42"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S("42")::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S("42")::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S::nullableTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S("42")::nullableTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + } + + global = S("") + assertEquals(S("42"), Z::nonNullTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.call()) + assertEquals(S("42"), Z::nonNullTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nonNullTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z::nullableTest.call(Z(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z(42)::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z(42)::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z::nullableTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z(42)::nullableTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + } + + global = S("") + assertEquals(S("42"), A::nonNullTest.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.call()) + assertEquals(S("42"), A::nonNullTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.getter.call()) + A::nonNullTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nonNullTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A::nullableTest.call(A(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A(42)::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A::nullableTest.getter.call(A(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A(42)::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A::nullableTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A(42)::nullableTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt new file mode 100644 index 00000000000..9d250f9f993 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt @@ -0,0 +1,49 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +interface ITest { + fun test(a: String, b: S, c: S?): String +} + +inline class S(val x: String?) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class Z(val x: Int) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) : ITest { + override fun test(a: String, b: S, c: S?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val plus = S("+") + val aster = S("*") + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", S::test.call(S("42"), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", S("42")::test.call("-", plus, aster)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", Z::test.call(Z(42), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", Z(42)::test.call("-", plus, aster)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", A::test.call(A("42"), "-", plus, aster)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("42-+*", A("42")::test.call("-", plus, aster)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt new file mode 100644 index 00000000000..70f8003bbb4 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt @@ -0,0 +1,154 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +var global = S("") + +interface ITest { + var nonNullTest: S + var nullableTest: S? +} + +inline class S(val x: String?) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class Z(val x: Int) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +inline class A(val x: Any) : ITest { + override var nonNullTest: S + get() = S("${global.x}$x") + set(value) { + global = S("${value.x}$x") + } + + override var nullableTest: S? + get() = S("${global.x}$x") + set(value) { + global = S("${value!!.x}$x") + } +} + +fun box(): String { + global = S("") + assertEquals(S("42"), S::nonNullTest.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.call()) + assertEquals(S("42"), S::nonNullTest.getter.call(S("42"))) + assertEquals(S("42"), S("42")::nonNullTest.getter.call()) + S::nonNullTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + S("42")::nonNullTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S::nullableTest.call(S("42"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S("42")::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S::nullableTest.getter.call(S("42"))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), S("42")::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S::nullableTest.setter.call(S("42"), S("S-")) + assertEquals(S("S-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S("42")::nullableTest.setter.call(S("S+")) + assertEquals(S("S+42"), global) + } + + global = S("") + assertEquals(S("42"), Z::nonNullTest.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.call()) + assertEquals(S("42"), Z::nonNullTest.getter.call(Z(42))) + assertEquals(S("42"), Z(42)::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + Z(42)::nonNullTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z::nullableTest.call(Z(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z(42)::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z::nullableTest.getter.call(Z(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), Z(42)::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z::nullableTest.setter.call(Z(42), S("Z-")) + assertEquals(S("Z-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z(42)::nullableTest.setter.call(S("Z+")) + assertEquals(S("Z+42"), global) + } + + global = S("") + assertEquals(S("42"), A::nonNullTest.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.call()) + assertEquals(S("42"), A::nonNullTest.getter.call(A(42))) + assertEquals(S("42"), A(42)::nonNullTest.getter.call()) + A::nonNullTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + A(42)::nonNullTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + + global = S("") + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A::nullableTest.call(A(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A(42)::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A::nullableTest.getter.call(A(42))) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(S("42"), A(42)::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A::nullableTest.setter.call(A(42), S("A-")) + assertEquals(S("A-42"), global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A(42)::nullableTest.setter.call(S("A+")) + assertEquals(S("A+42"), global) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt new file mode 100644 index 00000000000..09549635211 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt @@ -0,0 +1,135 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty2 +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: String?) { + operator fun plus(other: S): S = S(this.value!! + other.value!!) +} + +class C { + var nonNullMember: S = S("") + var nullableMember: S? = S("") + + private var suffix = S("") + var S.nonNull_nonNullMemExt: S + get() = this + suffix + set(value) { suffix = this + value } + + var S.nonNull_nullableMemExt: S? + get() = this + suffix + set(value) { suffix = this + value!! } + + var S?.nullable_nonNullMemExt: S + get() = this!! + suffix + set(value) { suffix = this!! + value } + + var S?.nullable_nullableMemExt: S? + get() = this!! + suffix + set(value) { suffix = this!! + value!! } +} + +var nonNullTopLevel: S = S("") +var nullableTopLevel: S? = S("") + +private var suffix = S("") +var S.nonNull_nonNullExt: S + get() = this + suffix + set(value) { suffix = this + value } + +var S.nonNull_nullableExt: S? + get() = this + suffix + set(value) { suffix = this + value!! } + +var S?.nullable_nonNullExt: S + get() = this!! + suffix + set(value) { suffix = this!! + value } + +var S?.nullable_nullableExt: S? + get() = this!! + suffix + set(value) { suffix = this!! + value!! } + +fun box(): String { + val c = C() + assertEquals(Unit, C::nonNullMember.setter.call(c, S("ab"))) + assertEquals(S("ab"), C::nonNullMember.call(c)) + assertEquals(S("ab"), C::nonNullMember.getter.call(c)) + + assertEquals(Unit, c::nonNullMember.setter.call(S("cd"))) + assertEquals(S("cd"), c::nonNullMember.call()) + assertEquals(S("cd"), c::nonNullMember.getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, C::nullableMember.setter.call(c, S("ab"))) + assertEquals(S("ab"), C::nullableMember.call(c)) + assertEquals(S("ab"), C::nullableMember.getter.call(c)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c::nullableMember.setter.call(S("cd"))) + assertEquals(S("cd"), c::nullableMember.call()) + assertEquals(S("cd"), c::nullableMember.getter.call()) + } + + val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2 + assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nonNull_nonNullMemExt.call(c, S("e"))) + assertEquals(S("ef"), nonNull_nonNullMemExt.getter.call(c, S("e"))) + + val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nonNull_nullableMemExt.call(c, S("e"))) + assertEquals(S("ef"), nonNull_nullableMemExt.getter.call(c, S("e"))) + } + + val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nullable_nonNullMemExt.call(c, S("e"))) + assertEquals(S("ef"), nullable_nonNullMemExt.getter.call(c, S("e"))) + } + + val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullable_nullableMemExt.setter.call(c, S(""), S("f"))) + assertEquals(S("ef"), nullable_nullableMemExt.call(c, S("e"))) + assertEquals(S("ef"), nullable_nullableMemExt.getter.call(c, S("e"))) + } + + assertEquals(Unit, ::nonNullTopLevel.setter.call(S("gh"))) + assertEquals(S("gh"), ::nonNullTopLevel.call()) + assertEquals(S("gh"), ::nonNullTopLevel.getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, ::nullableTopLevel.setter.call(S("gh"))) + assertEquals(S("gh"), ::nullableTopLevel.call()) + assertEquals(S("gh"), ::nullableTopLevel.getter.call()) + } + + assertEquals(Unit, S::nonNull_nonNullExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S::nonNull_nonNullExt.call(S("i"))) + assertEquals(S("ij"), S::nonNull_nonNullExt.getter.call(S("i"))) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, S::nonNull_nullableExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S::nonNull_nullableExt.call(S("i"))) + assertEquals(S("ij"), S::nonNull_nullableExt.getter.call(S("i"))) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, S?::nullable_nonNullExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S?::nullable_nonNullExt.call(S("i"))) + assertEquals(S("ij"), S?::nullable_nonNullExt.getter.call(S("i"))) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, S?::nullable_nullableExt.setter.call(S(""), S("j"))) + assertEquals(S("ij"), S?::nullable_nullableExt.call(S("i"))) + assertEquals(S("ij"), S?::nullable_nullableExt.getter.call(S("i"))) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt new file mode 100644 index 00000000000..515a1d4aca2 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt @@ -0,0 +1,70 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT +// WITH_COROUTINES + +import kotlin.coroutines.startCoroutine +import kotlin.reflect.full.callSuspend +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import helpers.* + +inline class S(val value: String?) + +class C { + private var value: S = S("") + + suspend fun nonNullConsume(z: S) { value = z } + suspend fun nonNullProduce(): S = value + suspend fun nullableConsume(z: S?) { value = z!! } + suspend fun nullableProduce(): S? = value + suspend fun nonNull_nonNullConsumeAndProduce(z: S): S = z + suspend fun nonNull_nullableConsumeAndProduce(z: S): S? = z + suspend fun nullable_nonNullConsumeAndProduce(z: S?): S = z!! + suspend fun nullable_nullableConsumeAndProduce(z: S?): S? = z +} + +private fun run0(f: suspend () -> String): String { + var result = "" + f.startCoroutine(handleResultContinuation { result = it }) + return result +} + +fun box(): String { + val c = C() + + run0 { + C::nonNullConsume.callSuspend(c, S("nonNull")) + C::nonNullProduce.callSuspend(c).value!! + }.let { assertEquals("nonNull", it) } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullableConsume.callSuspend(c, S("nullable")) + C::nullableProduce.callSuspend(c)!!.value!! + }.let { assertEquals("nullable", it) } + } + + run0 { + C::nonNull_nonNullConsumeAndProduce.callSuspend(c, S("nonNull_nonNull")).value!! + }.let { assertEquals("nonNull_nonNull", it) } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nonNull_nullableConsumeAndProduce.callSuspend(c, S("nonNull_nullable"))!!.value!! + }.let { assertEquals("nonNull_nullable", it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullable_nonNullConsumeAndProduce.callSuspend(c, S("nullable_nonNull")).value!! + }.let { assertEquals("nullable_nonNull", it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullable_nullableConsumeAndProduce.callSuspend(c, S("nullable_nullable"))!!.value!! + }.let { assertEquals("nullable_nullable", it) } + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt deleted file mode 100644 index ec000f781ec..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt +++ /dev/null @@ -1,40 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT -import kotlin.test.assertEquals - -interface ITest { - fun test(a: String, b: S): String -} - -inline class Z(val x: Int) : ITest { - override fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class L(val x: Long) : ITest { - override fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class S(val x: String) : ITest { - override fun test(a: String, b: S) = "$x$a${b.x}" -} - -inline class A(val x: Any) : ITest { - override fun test(a: String, b: S) = "$x$a${b.x}" -} - -fun box(): String { - assertEquals("42-+", Z::test.call(Z(42), "-", S("+"))) - assertEquals("42-+", Z(42)::test.call("-", S("+"))) - - assertEquals("42-+", L::test.call(L(42L), "-", S("+"))) - assertEquals("42-+", L(42L)::test.call("-", S("+"))) - - assertEquals("42-+", S::test.call(S("42"), "-", S("+"))) - assertEquals("42-+", S("42")::test.call("-", S("+"))) - - assertEquals("42-+", A::test.call(A("42"), "-", S("+"))) - assertEquals("42-+", A("42")::test.call("-", S("+"))) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt deleted file mode 100644 index 0ef10f74115..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt +++ /dev/null @@ -1,86 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT -import kotlin.test.assertEquals - -var global = S("") - -interface ITest { - var test: S -} - -inline class Z(val x: Int) : ITest { - override var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class L(val x: Long) : ITest { - override var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class S(val x: String) : ITest { - override var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -inline class A(val x: Any) : ITest { - override var test: S - get() = S("${global.x}$x") - set(value) { - global = S("${value.x}$x") - } -} - -fun box(): String { - global = S("") - assertEquals(S("42"), Z::test.call(Z(42))) - assertEquals(S("42"), Z(42)::test.call()) - assertEquals(S("42"), Z::test.getter.call(Z(42))) - assertEquals(S("42"), Z(42)::test.getter.call()) - Z::test.setter.call(Z(42), S("Z-")) - assertEquals(S("Z-42"), global) - Z(42)::test.setter.call(S("Z+")) - assertEquals(S("Z+42"), global) - - global = S("") - assertEquals(S("42"), L::test.call(L(42L))) - assertEquals(S("42"), L(42L)::test.call()) - assertEquals(S("42"), L::test.getter.call(L(42L))) - assertEquals(S("42"), L(42L)::test.getter.call()) - L::test.setter.call(L(42L), S("L-")) - assertEquals(S("L-42"), global) - L(42L)::test.setter.call(S("L+")) - assertEquals(S("L+42"), global) - - global = S("") - assertEquals(S("42"), S::test.call(S("42"))) - assertEquals(S("42"), S("42")::test.call()) - assertEquals(S("42"), S::test.getter.call(S("42"))) - assertEquals(S("42"), S("42")::test.getter.call()) - S::test.setter.call(S("42"), S("S-")) - assertEquals(S("S-42"), global) - S("42")::test.setter.call(S("S+")) - assertEquals(S("S+42"), global) - - global = S("") - assertEquals(S("42"), A::test.call(A(42))) - assertEquals(S("42"), A(42)::test.call()) - assertEquals(S("42"), A::test.getter.call(A(42))) - assertEquals(S("42"), A(42)::test.getter.call()) - A::test.setter.call(A(42), S("A-")) - assertEquals(S("A-42"), global) - A(42)::test.setter.call(S("A+")) - assertEquals(S("A+42"), global) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt index 23bda44c8e6..9de6164ee66 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt @@ -10,8 +10,11 @@ inline class Z2(val x: Z) inline class L(val x: Long) inline class L2(val x: L) -inline class A(val x: Any?) -inline class A2(val x: A) +inline class A1(val x: Any?) +inline class A1_2(val x: A1) + +inline class A2(val x: Any) +inline class A2_2(val x: A2) fun box(): String { assertEquals(42, Z::x.call(Z(42))) @@ -20,10 +23,10 @@ fun box(): String { assertEquals(1234L, L::x.call(L(1234L))) assertEquals(1234L, L(1234L)::x.call()) - assertEquals("abc", A::x.call(A("abc"))) - assertEquals("abc", A("abc")::x.call()) - assertEquals(null, A::x.call(A(null))) - assertEquals(null, A(null)::x.call()) + assertEquals("abc", A1::x.call(A1("abc"))) + assertEquals("abc", A1("abc")::x.call()) + assertEquals(null, A1::x.call(A1(null))) + assertEquals(null, A1(null)::x.call()) assertEquals(Z(42), Z2::x.call(Z2(Z(42)))) assertEquals(Z(42), Z2(Z(42))::x.call()) @@ -31,10 +34,12 @@ fun box(): String { assertEquals(L(1234L), L2::x.call(L2(L(1234L)))) assertEquals(L(1234L), L2(L(1234L))::x.call()) - assertEquals(A("abc"), A2::x.call(A2(A("abc")))) - assertEquals(A("abc"), A2(A("abc"))::x.call()) - assertEquals(A(null), A2::x.call(A2(A(null)))) - assertEquals(A(null), A2(A(null))::x.call()) + assertEquals(A1("abc"), A1_2::x.call(A1_2(A1("abc")))) + assertEquals(A1("abc"), A1_2(A1("abc"))::x.call()) + assertEquals(A1(null), A1_2::x.call(A1_2(A1(null)))) + assertEquals(A1(null), A1_2(A1(null))::x.call()) + assertEquals(A2("abc"), A2_2::x.call(A2_2(A2("abc")))) + assertEquals(A2("abc"), A2_2(A2("abc"))::x.call()) return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt new file mode 100644 index 00000000000..c1a52e7bf6c --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt @@ -0,0 +1,59 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class Z(val x: Int) + +class Outer(val z1: Z, val z2: Z?) { + inner class Inner(val z3: Z, val z4: Z?) { + val test = "$z1 $z2 $z3 $z4" + } +} + +inline class InlineNonNullOuter(val z1: Z) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: Z, val z3: Z?) { + val test = "$z1 $z2 $z3" + } +} + +inline class InlineNullableOuter(val z1: Z?) { + @Suppress("INNER_CLASS_INSIDE_VALUE_CLASS") + inner class Inner(val z2: Z, val z3: Z?) { + val test = "$z1 $z2 $z3" + } +} + +fun box(): String { + val z1 = Z(1) + val z2 = Z(2) + val z3 = Z(3) + val z4 = Z(4) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + val outer = ::Outer.call(z1, z2) + assertEquals(z1, outer.z1) + assertEquals(z2, outer.z2) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("Z(x=1) Z(x=2) Z(x=3) Z(x=4)", Outer::Inner.call(outer, z3, z4).test) + assertEquals("Z(x=1) Z(x=2) Z(x=2) Z(x=4)", outer::Inner.call(z2, z4).test) + } + } + + val inlineNonNullOuter = InlineNonNullOuter(z1) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNonNullOuter::Inner.call(inlineNonNullOuter, z2, z3).test) + assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNonNullOuter::Inner.call(z2, z2).test) + } + + val inlineNullableOuter = InlineNullableOuter(z1) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("Z(x=1) Z(x=2) Z(x=3)", InlineNullableOuter::Inner.call(inlineNullableOuter, z2, z3).test) + assertEquals("Z(x=1) Z(x=2) Z(x=2)", inlineNullableOuter::Inner.call(z2, z2).test) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt new file mode 100644 index 00000000000..8bc5121ae1f --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt @@ -0,0 +1,64 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: Int) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + private var nonNullMember: S = S(-1) + private var nullableMember: S? = S(-1) + + fun nonNullUnboundRef() = C::nonNullMember.apply { isAccessible = true } + fun nonNullBoundRef() = this::nonNullMember.apply { isAccessible = true } + fun nullableUnboundRef() = C::nullableMember.apply { isAccessible = true } + fun nullableBoundRef() = this::nullableMember.apply { isAccessible = true } +} + +private var nonNullTopLevel: S = S(-1) +private var nullableTopLevel: S? = S(-1) + +fun box(): String { + val c = C() + val zero = S(0) + val one = S(1) + val two = S(2) + + assertEquals(Unit, c.nonNullUnboundRef().setter.call(c, zero)) + assertEquals(zero, c.nonNullUnboundRef().call(c)) + assertEquals(zero, c.nonNullUnboundRef().getter.call(c)) + + assertEquals(Unit, c.nonNullBoundRef().setter.call(one)) + assertEquals(one, c.nonNullBoundRef().call()) + assertEquals(one, c.nonNullBoundRef().getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c.nullableUnboundRef().setter.call(c, zero)) + assertEquals(zero, c.nullableUnboundRef().call(c)) + assertEquals(zero, c.nullableUnboundRef().getter.call(c)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c.nullableBoundRef().setter.call(one)) + assertEquals(one, c.nullableBoundRef().call()) + assertEquals(one, c.nullableBoundRef().getter.call()) + } + + val nonNullTopLevel = ::nonNullTopLevel.apply { isAccessible = true } + assertEquals(Unit, nonNullTopLevel.setter.call(two)) + assertEquals(two, nonNullTopLevel.call()) + assertEquals(two, nonNullTopLevel.getter.call()) + + val nullableTopLevel = ::nullableTopLevel.apply { isAccessible = true } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableTopLevel.setter.call(two)) + assertEquals(two, nullableTopLevel.call()) + assertEquals(two, nullableTopLevel.getter.call()) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt new file mode 100644 index 00000000000..44e7e295c3b --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt @@ -0,0 +1,64 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class S(val value: Int) { + operator fun plus(other: S): S = S(this.value + other.value) +} + +class C { + fun member(x: S, y: Int, z: S?): S = x + S(y) + z!! +} + +fun topLevel(x: Int, y: S, z: S?): S = S(x) + y + z!! + +fun S.extension1(y: S, z: S?): S = this + y + z!! + +fun S?.extension2(y: S, z: S?) = this!! + y + z!! + +fun S.extension3(): Int = value + +fun S?.extension4(): Int = this!!.value + +fun box(): String { + val zero = S(0) + val one = S(1) + val two = S(2) + val four = S(4) + val seven = S(7) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, C::member.call(C(), one, 2, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, ::topLevel.call(1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, S::extension1.call(one, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, S::extension2.call(one, two, four)) + } + assertEquals(0, S::extension3.call(zero)) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(0, S?::extension4.call(zero)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, C()::member.call(one, 2, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, one::extension1.call(two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, one::extension2.call(two, four)) + } + assertEquals(0, zero::extension3.call()) + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(0, zero::extension4.call(zero)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt new file mode 100644 index 00000000000..439cac33737 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt @@ -0,0 +1,56 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty1 +import kotlin.reflect.jvm.isAccessible +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class Z(val value: Int) { + operator fun plus(other: Z): Z = Z(this.value + other.value) +} + +object C { + @JvmStatic + private var p1: Z = Z(-1) + + @JvmStatic + private var p2: Z? = Z(-1) + + fun nonNullBoundRef() = this::p1.apply { isAccessible = true } + fun nullableBoundRef() = this::p2.apply { isAccessible = true } +} + +fun box(): String { + val one = Z(1) + val two = Z(2) + + val nonNullUnboundRef = C::class.members.single { it.name == "p1" } as KMutableProperty1 + nonNullUnboundRef.isAccessible = true + assertEquals(Unit, nonNullUnboundRef.setter.call(C, one)) + assertEquals(one, nonNullUnboundRef.call(C)) + assertEquals(one, nonNullUnboundRef.getter.call(C)) + + val nullableUnboundRef = C::class.members.single { it.name == "p2" } as KMutableProperty1 + nullableUnboundRef.isAccessible = true + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableUnboundRef.setter.call(C, one)) + assertEquals(one, nullableUnboundRef.call(C)) + assertEquals(one, nullableUnboundRef.getter.call(C)) + } + + val nonNullBoundRef = C.nonNullBoundRef() + assertEquals(Unit, nonNullBoundRef.setter.call(two)) + assertEquals(two, nonNullBoundRef.call()) + assertEquals(two, nonNullBoundRef.getter.call()) + + val nullableBoundRef = C.nullableBoundRef() + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullableBoundRef.setter.call(two)) + assertEquals(two, nullableBoundRef.call()) + assertEquals(two, nullableBoundRef.getter.call()) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt new file mode 100644 index 00000000000..da8cd2dc8f2 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt @@ -0,0 +1,49 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_REFLECT + +import kotlin.reflect.KFunction +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class Z(val value: Int) { + operator fun plus(other: Z): Z = Z(this.value + other.value) +} + +object C { + @JvmStatic + fun foo(x: Z, y: Int, z: Z?): Z = x + Z(y) + z!! +} + +interface I { + companion object { + @JvmStatic + fun bar(x: Int, y: Z, z: Z?): Z = Z(x) + y + z!! + } +} + +fun box(): String { + val one = Z(1) + val two = Z(2) + val four = Z(4) + val seven = Z(7) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, C::foo.call(one, 2, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, (I)::bar.call(1, two, four)) + } + + val unboundFoo = C::class.members.single { it.name == "foo" } as KFunction<*> + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, unboundFoo.call(C, one, 2, four)) + } + + val unboundBar = I.Companion::class.members.single { it.name == "bar" } as KFunction<*> + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(seven, unboundBar.call(I, 1, two, four)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt new file mode 100644 index 00000000000..f42dd590334 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt @@ -0,0 +1,45 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class Z(val x: Int) { + fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +inline class S(val x: String) { + fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) { + fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val two = Z(2) + val four = Z(4) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", Z::test.call(Z(0), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", Z(0)::test.call(1, two, four)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", S::test.call(S("0"), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", S("0")::test.call(1, two, four)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", A::test.call(A(0), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", A(0)::test.call(1, two, four)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt new file mode 100644 index 00000000000..f8430b7f2c5 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt @@ -0,0 +1,160 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +var global = Z(0) + +inline class Z(val x: Int) { + var nonNullTest: Z + get() = Z(global.x + this.x) + set(value) { + global = Z(this.x + value.x) + } + + var nullableTest: Z? + get() = Z(global.x + this.x) + set(value) { + global = Z(this.x + value!!.x) + } +} + +inline class S(val x: String) { + var nonNullTest: Z + get() = Z(global.x + x.toInt()) + set(value) { + global = Z(this.x.toInt() + value.x) + } + + var nullableTest: Z? + get() = Z(global.x + x.toInt()) + set(value) { + global = Z(this.x.toInt() + value!!.x) + } +} + +inline class A(val x: Any) { + var nonNullTest: Z + get() = Z(global.x + this.x as Int) + set(value) { + global = Z(this.x as Int + value.x) + } + + var nullableTest: Z? + get() = Z(global.x + this.x as Int) + set(value) { + global = Z(this.x as Int + value!!.x) + } + +} + +fun box(): String { + val zZero = Z(0) + val zOne = Z(1) + val zTwo = Z(2) + val zThree = Z(3) + val zFour = Z(4) + + val sOne = S("1") + + val aOne = A(1) + + global = zZero + assertEquals(zOne, Z::nonNullTest.call(zOne)) + assertEquals(zOne, zOne::nonNullTest.call()) + assertEquals(zOne, Z::nonNullTest.getter.call(zOne)) + assertEquals(zOne, zOne::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(zOne, zTwo) + assertEquals(zThree, global) + zOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, Z::nullableTest.call(zOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, zOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, Z::nullableTest.getter.call(zOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, zOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z::nullableTest.setter.call(zOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + zOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + global = zZero + assertEquals(zOne, S::nonNullTest.call(sOne)) + assertEquals(zOne, sOne::nonNullTest.call()) + assertEquals(zOne, S::nonNullTest.getter.call(sOne)) + assertEquals(zOne, sOne::nonNullTest.getter.call()) + S::nonNullTest.setter.call(sOne, zTwo) + assertEquals(zThree, global) + sOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, S::nullableTest.call(sOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, sOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, S::nullableTest.getter.call(sOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, sOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S::nullableTest.setter.call(sOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + sOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + global = zZero + assertEquals(zOne, A::nonNullTest.call(aOne)) + assertEquals(zOne, aOne::nonNullTest.call()) + assertEquals(zOne, A::nonNullTest.getter.call(aOne)) + assertEquals(zOne, aOne::nonNullTest.getter.call()) + A::nonNullTest.setter.call(aOne, zTwo) + assertEquals(zThree, global) + aOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, A::nullableTest.call(aOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, aOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, A::nullableTest.getter.call(aOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, aOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A::nullableTest.setter.call(aOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + aOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt new file mode 100644 index 00000000000..7db00a30852 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt @@ -0,0 +1,49 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +interface ITest { + fun test(a: Int, b: Z, c: Z?): String +} + +inline class Z(val x: Int) : ITest { + override fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +inline class S(val x: String) : ITest { + override fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +inline class A(val x: Any) : ITest { + override fun test(a: Int, b: Z, c: Z?) = "$x$a${b.x}${c!!.x}" +} + +fun box(): String { + val two = Z(2) + val four = Z(4) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", Z::test.call(Z(0), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", Z(0)::test.call(1, two, four)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", S::test.call(S("0"), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", S("0")::test.call(1, two, four)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", A::test.call(A(0), 1, two, four)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals("0124", A(0)::test.call(1, two, four)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt new file mode 100644 index 00000000000..594c478e897 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt @@ -0,0 +1,165 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +var global = Z(0) + +interface ITest { + var nonNullTest: Z + var nullableTest: Z? +} + +inline class Z(val x: Int) : ITest { + override var nonNullTest: Z + get() = Z(global.x + this.x) + set(value) { + global = Z(this.x + value.x) + } + + override var nullableTest: Z? + get() = Z(global.x + this.x) + set(value) { + global = Z(this.x + value!!.x) + } +} + +inline class S(val x: String) : ITest { + override var nonNullTest: Z + get() = Z(global.x + x.toInt()) + set(value) { + global = Z(this.x.toInt() + value.x) + } + + override var nullableTest: Z? + get() = Z(global.x + x.toInt()) + set(value) { + global = Z(this.x.toInt() + value!!.x) + } +} + +inline class A(val x: Any) : ITest { + override var nonNullTest: Z + get() = Z(global.x + this.x as Int) + set(value) { + global = Z(this.x as Int + value.x) + } + + override var nullableTest: Z? + get() = Z(global.x + this.x as Int) + set(value) { + global = Z(this.x as Int + value!!.x) + } + +} + +fun box(): String { + val zZero = Z(0) + val zOne = Z(1) + val zTwo = Z(2) + val zThree = Z(3) + val zFour = Z(4) + + val sOne = S("1") + + val aOne = A(1) + + global = zZero + assertEquals(zOne, Z::nonNullTest.call(zOne)) + assertEquals(zOne, zOne::nonNullTest.call()) + assertEquals(zOne, Z::nonNullTest.getter.call(zOne)) + assertEquals(zOne, zOne::nonNullTest.getter.call()) + Z::nonNullTest.setter.call(zOne, zTwo) + assertEquals(zThree, global) + zOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, Z::nullableTest.call(zOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, zOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, Z::nullableTest.getter.call(zOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, zOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + Z::nullableTest.setter.call(zOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + zOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + global = zZero + assertEquals(zOne, S::nonNullTest.call(sOne)) + assertEquals(zOne, sOne::nonNullTest.call()) + assertEquals(zOne, S::nonNullTest.getter.call(sOne)) + assertEquals(zOne, sOne::nonNullTest.getter.call()) + S::nonNullTest.setter.call(sOne, zTwo) + assertEquals(zThree, global) + sOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, S::nullableTest.call(sOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, sOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, S::nullableTest.getter.call(sOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, sOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + S::nullableTest.setter.call(sOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + sOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + global = zZero + assertEquals(zOne, A::nonNullTest.call(aOne)) + assertEquals(zOne, aOne::nonNullTest.call()) + assertEquals(zOne, A::nonNullTest.getter.call(aOne)) + assertEquals(zOne, aOne::nonNullTest.getter.call()) + A::nonNullTest.setter.call(aOne, zTwo) + assertEquals(zThree, global) + aOne::nonNullTest.setter.call(zThree) + assertEquals(zFour, global) + + global = zZero + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, A::nullableTest.call(aOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, aOne::nullableTest.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, A::nullableTest.getter.call(aOne)) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(zOne, aOne::nullableTest.getter.call()) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + A::nullableTest.setter.call(aOne, zTwo) + assertEquals(zThree, global) + } + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + aOne::nullableTest.setter.call(zThree) + assertEquals(zFour, global) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt new file mode 100644 index 00000000000..a9ceda650bd --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt @@ -0,0 +1,139 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +import kotlin.reflect.KMutableProperty2 +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith + +inline class Z(val value: Int) { + operator fun plus(other: Z): Z = Z(this.value + other.value) +} + +class C { + var nonNullMember: Z = Z(0) + var nullableMember: Z? = Z(0) + + private var offset = Z(0) + var Z.nonNull_nonNullMemExt: Z + get() = this + offset + set(value) { offset = this + value } + + var Z.nonNull_nullableMemExt: Z? + get() = this + offset + set(value) { offset = this + value!! } + + var Z?.nullable_nonNullMemExt: Z + get() = this!! + offset + set(value) { offset = this!! + value } + + var Z?.nullable_nullableMemExt: Z? + get() = this!! + offset + set(value) { offset = this!! + value!! } +} + +var nonNullTopLevel: Z = Z(0) +var nullableTopLevel: Z? = Z(0) + +private var offset = Z(0) +var Z.nonNull_nonNullExt: Z + get() = this + offset + set(value) { offset = this + value } + +var Z.nonNull_nullableExt: Z? + get() = this + offset + set(value) { offset = this + value!! } + +var Z?.nullable_nonNullExt: Z + get() = this!! + offset + set(value) { offset = this!! + value } + +var Z?.nullable_nullableExt: Z? + get() = this!! + offset + set(value) { offset = this!! + value!! } + +fun box(): String { + val one = Z(1) + val two = Z(2) + val three = Z(3) + + val c = C() + assertEquals(Unit, C::nonNullMember.setter.call(c, one)) + assertEquals(one, C::nonNullMember.call(c)) + assertEquals(one, C::nonNullMember.getter.call(c)) + + assertEquals(Unit, c::nonNullMember.setter.call(two)) + assertEquals(two, c::nonNullMember.call()) + assertEquals(two, c::nonNullMember.getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, C::nullableMember.setter.call(c, one)) + assertEquals(one, C::nullableMember.call(c)) + assertEquals(one, C::nullableMember.getter.call(c)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, c::nullableMember.setter.call(two)) + assertEquals(two, c::nullableMember.call()) + assertEquals(two, c::nullableMember.getter.call()) + } + + val nonNull_nonNullMemExt = C::class.members.single { it.name == "nonNull_nonNullMemExt" } as KMutableProperty2 + assertEquals(Unit, nonNull_nonNullMemExt.setter.call(c, Z(0), two)) + assertEquals(three, nonNull_nonNullMemExt.call(c, one)) + assertEquals(three, nonNull_nonNullMemExt.getter.call(c, one)) + + val nonNull_nullableMemExt = C::class.members.single { it.name == "nonNull_nullableMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nonNull_nullableMemExt.setter.call(c, Z(0), two)) + assertEquals(three, nonNull_nullableMemExt.call(c, one)) + assertEquals(three, nonNull_nullableMemExt.getter.call(c, one)) + } + + val nullable_nonNullMemExt = C::class.members.single { it.name == "nullable_nonNullMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullable_nonNullMemExt.setter.call(c, Z(0), two)) + assertEquals(three, nullable_nonNullMemExt.call(c, one)) + assertEquals(three, nullable_nonNullMemExt.getter.call(c, one)) + } + + val nullable_nullableMemExt = C::class.members.single { it.name == "nullable_nullableMemExt" } as KMutableProperty2 + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, nullable_nullableMemExt.setter.call(c, Z(0), two)) + assertEquals(three, nullable_nullableMemExt.call(c, one)) + assertEquals(three, nullable_nullableMemExt.getter.call(c, one)) + } + + assertEquals(Unit, ::nonNullTopLevel.setter.call(one)) + assertEquals(one, ::nonNullTopLevel.call()) + assertEquals(one, ::nonNullTopLevel.getter.call()) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, ::nullableTopLevel.setter.call(one)) + assertEquals(one, ::nullableTopLevel.call()) + assertEquals(one, ::nullableTopLevel.getter.call()) + } + + assertEquals(Unit, Z::nonNull_nonNullExt.setter.call(Z(0), two)) + assertEquals(three, Z::nonNull_nonNullExt.call(one)) + assertEquals(three, Z::nonNull_nonNullExt.getter.call(one)) + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, Z::nonNull_nullableExt.setter.call(Z(0), two)) + assertEquals(three, Z::nonNull_nullableExt.call(one)) + assertEquals(three, Z::nonNull_nullableExt.getter.call(one)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, Z?::nullable_nonNullExt.setter.call(Z(0), two)) + assertEquals(three, Z?::nullable_nonNullExt.call(one)) + assertEquals(three, Z?::nullable_nonNullExt.getter.call(one)) + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + assertEquals(Unit, Z?::nullable_nullableExt.setter.call(Z(0), two)) + assertEquals(three, Z?::nullable_nullableExt.call(one)) + assertEquals(three, Z?::nullable_nullableExt.getter.call(one)) + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt new file mode 100644 index 00000000000..1f0f8a43cd1 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt @@ -0,0 +1,74 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT +// WITH_COROUTINES + +import kotlin.coroutines.startCoroutine +import kotlin.reflect.full.callSuspend +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import helpers.* + +inline class Z(val value: Int) + +class C { + private var value: Z = Z(0) + + suspend fun nonNullConsume(z: Z) { value = z } + suspend fun nonNullProduce(): Z = value + suspend fun nullableConsume(z: Z?) { value = z!! } + suspend fun nullableProduce(): Z? = value + suspend fun nonNull_nonNullConsumeAndProduce(z: Z): Z = z + suspend fun nonNull_nullableConsumeAndProduce(z: Z): Z? = z + suspend fun nullable_nonNullConsumeAndProduce(z: Z?): Z = z!! + suspend fun nullable_nullableConsumeAndProduce(z: Z?): Z? = z +} + +private fun run0(f: suspend () -> Int): Int { + var result = -1 + f.startCoroutine(handleResultContinuation { result = it }) + return result +} + +fun box(): String { + val c = C() + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nonNullConsume.callSuspend(c, Z(1)) + C::nonNullProduce.callSuspend(c).value + }.let { assertEquals(1, it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullableConsume.callSuspend(c, Z(2)) + C::nullableProduce.callSuspend(c)!!.value + }.let { assertEquals(2, it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nonNull_nonNullConsumeAndProduce.callSuspend(c, Z(3)).value + }.let { assertEquals(3, it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nonNull_nullableConsumeAndProduce.callSuspend(c, Z(4))!!.value + }.let { assertEquals(4, it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullable_nonNullConsumeAndProduce.callSuspend(c, Z(5)).value + }.let { assertEquals(5, it) } + } + + assertFailsWith("Remove assertFailsWith and try again, as this problem may have been fixed.") { + run0 { + C::nullable_nullableConsumeAndProduce.callSuspend(c, Z(6))!!.value + }.let { assertEquals(6, it) } + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt deleted file mode 100644 index 5e55320d0b7..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt +++ /dev/null @@ -1,52 +0,0 @@ -// IGNORE_BACKEND: JS_IR, JS, NATIVE, WASM -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_REFLECT - -import kotlin.reflect.KMutableProperty2 -import kotlin.test.assertEquals - -inline class S(val value: String) { - operator fun plus(other: S): S = S(this.value + other.value) -} - -class C { - var member: S = S("") - - private var suffix = S("") - var S.memExt: S - get() = this + suffix - set(value) { suffix = this + value } -} - -var topLevel: S = S("") - -private var suffix = S("") -var S.ext: S - get() = this + suffix - set(value) { suffix = this + value } - -fun box(): String { - val c = C() - assertEquals(Unit, C::member.setter.call(c, S("ab"))) - assertEquals(S("ab"), C::member.call(c)) - assertEquals(S("ab"), C::member.getter.call(c)) - - assertEquals(Unit, c::member.setter.call(S("cd"))) - assertEquals(S("cd"), c::member.call()) - assertEquals(S("cd"), c::member.getter.call()) - - val memExt = C::class.members.single { it.name == "memExt" } as KMutableProperty2 - assertEquals(Unit, memExt.setter.call(c, S(""), S("f"))) - assertEquals(S("ef"), memExt.call(c, S("e"))) - assertEquals(S("ef"), memExt.getter.call(c, S("e"))) - - assertEquals(Unit, ::topLevel.setter.call(S("gh"))) - assertEquals(S("gh"), ::topLevel.call()) - assertEquals(S("gh"), ::topLevel.getter.call()) - - assertEquals(Unit, S::ext.setter.call(S(""), S("j"))) - assertEquals(S("ij"), S::ext.call(S("i"))) - assertEquals(S("ij"), S::ext.getter.call(S("i"))) - - return "OK" -} diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt deleted file mode 100644 index f41c33180e6..00000000000 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt +++ /dev/null @@ -1,34 +0,0 @@ -// TARGET_BACKEND: JVM -// WITH_REFLECT -// WITH_COROUTINES - -package test - -import kotlin.coroutines.startCoroutine -import kotlin.reflect.full.callSuspend -import helpers.* - -inline class Z(val value: String) - -class S { - private var value: Z = Z("") - - suspend fun consumeZ(z: Z) { value = z } - suspend fun produceZ(): Z = value - suspend fun consumeAndProduceZ(z: Z): Z = z -} - -private fun run0(f: suspend () -> String): String { - var result = "" - f.startCoroutine(handleResultContinuation { result = it }) - return result -} - -fun box(): String = - run0 { - val s = S() - S::consumeZ.callSuspend(s, Z("z")) - val v = S::produceZ.callSuspend(s) - if (v != Z("z")) "Fail: $v" - else S::consumeAndProduceZ.callSuspend(s, Z("OK")).value - } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 8840ff41228..5bb23f7033c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -39733,24 +39733,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("fieldAccessors.kt") - public void testFieldAccessors() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -39763,58 +39745,238 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("jvmStaticFieldInObject.kt") - public void testJvmStaticFieldInObject() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt"); - } - - @Test - @TestMetadata("jvmStaticFunction.kt") - public void testJvmStaticFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt"); - } - - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt"); + } } - @Test - @TestMetadata("suspendFunction.kt") - public void testSuspendFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt"); + } } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index db05a8adce4..183fc9998a3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -40225,24 +40225,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("fieldAccessors.kt") - public void testFieldAccessors() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -40255,58 +40237,238 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("jvmStaticFieldInObject.kt") - public void testJvmStaticFieldInObject() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt"); - } - - @Test - @TestMetadata("jvmStaticFunction.kt") - public void testJvmStaticFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt"); - } - - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt"); + } } - @Test - @TestMetadata("suspendFunction.kt") - public void testSuspendFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt"); + } + + @Test + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt"); + } + + @Test + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt"); + } + + @Test + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt"); + } + + @Test + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt"); + } + + @Test + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt"); + } + + @Test + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt"); + } + + @Test + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt"); + } } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index a26d694d57b..2818342beb5 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -31765,21 +31765,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @TestMetadata("fieldAccessors.kt") - public void testFieldAccessors() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/fieldAccessors.kt"); - } - - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt"); @@ -31790,49 +31775,213 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @TestMetadata("jvmStaticFieldInObject.kt") - public void testJvmStaticFieldInObject() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFieldInObject.kt"); - } - - @TestMetadata("jvmStaticFunction.kt") - public void testJvmStaticFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/jvmStaticFunction.kt"); - } - - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NonNullObject extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/constructorWithInlineClassParameters.kt"); + } + + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/fieldAccessors.kt"); + } + + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/functionsWithInlineClassParameters.kt"); + } + + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFieldInObject.kt"); + } + + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/jvmStaticFunction.kt"); + } + + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingFunOfInlineClass.kt"); + } + + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/nonOverridingVarOfInlineClass.kt"); + } + + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingFunOfInlineClass.kt"); + } + + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/overridingVarOfInlineClass.kt"); + } + + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/properties.kt"); + } + + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject/suspendFunction.kt"); + } } - @TestMetadata("suspendFunction.kt") - public void testSuspendFunction() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/suspendFunction.kt"); + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullableObject extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/constructorWithInlineClassParameters.kt"); + } + + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/fieldAccessors.kt"); + } + + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/functionsWithInlineClassParameters.kt"); + } + + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFieldInObject.kt"); + } + + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/jvmStaticFunction.kt"); + } + + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingFunOfInlineClass.kt"); + } + + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/nonOverridingVarOfInlineClass.kt"); + } + + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingFunOfInlineClass.kt"); + } + + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/overridingVarOfInlineClass.kt"); + } + + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/properties.kt"); + } + + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject/suspendFunction.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Primitive extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/constructorWithInlineClassParameters.kt"); + } + + @TestMetadata("fieldAccessors.kt") + public void testFieldAccessors() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/fieldAccessors.kt"); + } + + @TestMetadata("functionsWithInlineClassParameters.kt") + public void testFunctionsWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/functionsWithInlineClassParameters.kt"); + } + + @TestMetadata("jvmStaticFieldInObject.kt") + public void testJvmStaticFieldInObject() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFieldInObject.kt"); + } + + @TestMetadata("jvmStaticFunction.kt") + public void testJvmStaticFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/jvmStaticFunction.kt"); + } + + @TestMetadata("nonOverridingFunOfInlineClass.kt") + public void testNonOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingFunOfInlineClass.kt"); + } + + @TestMetadata("nonOverridingVarOfInlineClass.kt") + public void testNonOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/nonOverridingVarOfInlineClass.kt"); + } + + @TestMetadata("overridingFunOfInlineClass.kt") + public void testOverridingFunOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingFunOfInlineClass.kt"); + } + + @TestMetadata("overridingVarOfInlineClass.kt") + public void testOverridingVarOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/overridingVarOfInlineClass.kt"); + } + + @TestMetadata("properties.kt") + public void testProperties() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/properties.kt"); + } + + @TestMetadata("suspendFunction.kt") + public void testSuspendFunction() throws Exception { + runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive/suspendFunction.kt"); + } } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index f110f20d811..b34acf5b177 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -30195,18 +30195,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -30219,40 +30207,40 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index dbe64716a9a..7c99d1a97f3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -30297,18 +30297,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -30321,40 +30309,40 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 3581b6f8606..67edb3bbc04 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -25062,16 +25062,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/inlineClassConstructor.kt"); @@ -25082,34 +25072,48 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NonNullObject extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullableObject extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Primitive extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } } } } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 198639eac1a..102b885f737 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -33200,18 +33200,6 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } - @Test - @TestMetadata("constructorWithInlineClassParameters.kt") - public void testConstructorWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/constructorWithInlineClassParameters.kt"); - } - - @Test - @TestMetadata("functionsWithInlineClassParameters.kt") - public void testFunctionsWithInlineClassParameters() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/functionsWithInlineClassParameters.kt"); - } - @Test @TestMetadata("inlineClassConstructor.kt") public void testInlineClassConstructor() throws Exception { @@ -33224,40 +33212,46 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/internalPrimaryValOfInlineClass.kt"); } - @Test - @TestMetadata("nonOverridingFunOfInlineClass.kt") - public void testNonOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("nonOverridingVarOfInlineClass.kt") - public void testNonOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingFunOfInlineClass.kt") - public void testOverridingFunOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingFunOfInlineClass.kt"); - } - - @Test - @TestMetadata("overridingVarOfInlineClass.kt") - public void testOverridingVarOfInlineClass() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt"); - } - @Test @TestMetadata("primaryValOfInlineClass.kt") public void testPrimaryValOfInlineClass() throws Exception { runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt"); } - @Test - @TestMetadata("properties.kt") - public void testProperties() throws Exception { - runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt"); + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class NonNullObject { + @Test + public void testAllFilesPresentInNonNullObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class NullableObject { + @Test + public void testAllFilesPresentInNullableObject() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/nullableObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @UseExtTestCaseGroupProvider() + public class Primitive { + @Test + public void testAllFilesPresentInPrimitive() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/call/inlineClasses/primitive"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } } } }