Fix ArrayStoreException from InlineClassAwareCaller.call
#KT-56650 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
10e9ef349f
commit
b039f2e574
+6
@@ -43019,6 +43019,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("simpleConstructorWithInlineClassParameter.kt")
|
||||||
|
public void testSimpleConstructorWithInlineClassParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/simpleConstructorWithInlineClassParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+6
@@ -43019,6 +43019,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("simpleConstructorWithInlineClassParameter.kt")
|
||||||
|
public void testSimpleConstructorWithInlineClassParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/simpleConstructorWithInlineClassParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// WITH_REFLECT
|
||||||
|
|
||||||
|
@JvmInline
|
||||||
|
value class Value(val value: String)
|
||||||
|
|
||||||
|
class A(val result: Value)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val args: Array<Value> = arrayOf(Value("OK"))
|
||||||
|
|
||||||
|
val a = (::A).call(*args)
|
||||||
|
return a.result.value
|
||||||
|
}
|
||||||
+6
@@ -40901,6 +40901,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("simpleConstructorWithInlineClassParameter.kt")
|
||||||
|
public void testSimpleConstructorWithInlineClassParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/simpleConstructorWithInlineClassParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+6
@@ -43019,6 +43019,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("simpleConstructorWithInlineClassParameter.kt")
|
||||||
|
public void testSimpleConstructorWithInlineClassParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/simpleConstructorWithInlineClassParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+5
@@ -32674,6 +32674,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/primaryValOfInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleConstructorWithInlineClassParameter.kt")
|
||||||
|
public void testSimpleConstructorWithInlineClassParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/call/inlineClasses/simpleConstructorWithInlineClassParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
@TestMetadata("compiler/testData/codegen/box/reflection/call/inlineClasses/nonNullObject")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+13
-8
@@ -125,16 +125,21 @@ internal class InlineClassAwareCaller<out M : Member?>(
|
|||||||
val (range, unbox, box) = data
|
val (range, unbox, box) = data
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val unboxed = args.copyOf() as Array<Any?>
|
val unboxed = Array(args.size) { index ->
|
||||||
for (index in range) {
|
|
||||||
val method = unbox[index]
|
|
||||||
val arg = args[index]
|
val arg = args[index]
|
||||||
// Note that arg may be null in case we're calling a $default method and it's an optional parameter of an inline class type
|
|
||||||
unboxed[index] = if (method != null) {
|
if (index in range) {
|
||||||
if (arg != null) {
|
// Note that arg may be null in case we're calling a $default method and it's an optional parameter of an inline class type
|
||||||
method.invoke(arg)
|
val method = unbox[index]
|
||||||
|
|
||||||
|
if (method != null) {
|
||||||
|
if (arg != null) {
|
||||||
|
method.invoke(arg)
|
||||||
|
} else {
|
||||||
|
defaultPrimitiveValue(method.returnType)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
defaultPrimitiveValue(method.returnType)
|
arg
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arg
|
arg
|
||||||
|
|||||||
Reference in New Issue
Block a user