JVM_IR KT-46092 fix array spread operator in Kotlin->Java call
This commit is contained in:
committed by
TeamCityServer
parent
b5fae96934
commit
cc415f62b5
+6
@@ -41056,6 +41056,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/vararg/kt45187.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt46092.kt")
|
||||
public void testKt46092() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt46092.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt581.kt")
|
||||
public void testKt581() throws Exception {
|
||||
|
||||
@@ -745,13 +745,13 @@ class JvmSymbols(
|
||||
}
|
||||
}
|
||||
|
||||
private val arraysCopyOfFunctions = HashMap<IrSimpleType, IrSimpleFunction>()
|
||||
private val arraysCopyOfFunctions = HashMap<IrClassifierSymbol, IrSimpleFunction>()
|
||||
|
||||
private fun IrClass.addArraysCopyOfFunction(arrayType: IrSimpleType) {
|
||||
addFunction("copyOf", arrayType, isStatic = true).apply {
|
||||
addValueParameter("original", arrayType)
|
||||
addValueParameter("newLength", irBuiltIns.intType)
|
||||
arraysCopyOfFunctions[arrayType] = this
|
||||
arraysCopyOfFunctions[arrayType.classifierOrFail] = this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,15 +771,12 @@ class JvmSymbols(
|
||||
}
|
||||
|
||||
fun getArraysCopyOfFunction(arrayType: IrSimpleType): IrSimpleFunctionSymbol {
|
||||
val copyOf = arraysCopyOfFunctions[arrayType]
|
||||
return when {
|
||||
copyOf != null ->
|
||||
copyOf.symbol
|
||||
arrayType.classifierOrFail == array ->
|
||||
arraysCopyOfFunctions[arrayOfAnyNType]!!.symbol
|
||||
else ->
|
||||
throw AssertionError("Array type expected: ${arrayType.render()}")
|
||||
}
|
||||
val classifier = arrayType.classifier
|
||||
val copyOf = arraysCopyOfFunctions[classifier]
|
||||
if (copyOf != null)
|
||||
return copyOf.symbol
|
||||
else
|
||||
throw AssertionError("Array type expected: ${arrayType.render()}")
|
||||
}
|
||||
|
||||
private val javaLangInteger: IrClassSymbol = createClass(FqName("java.lang.Integer")) { klass ->
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FILE: kt46092.kt
|
||||
|
||||
class CharSequenceBackedByChars : CharArrayCharSequence {
|
||||
constructor(chars: CharArray) : super(*chars)
|
||||
|
||||
fun test(): String = string
|
||||
}
|
||||
|
||||
fun box() = CharSequenceBackedByChars(charArrayOf('O', 'K')).test()
|
||||
|
||||
// FILE: CharArrayCharSequence.java
|
||||
|
||||
public class CharArrayCharSequence {
|
||||
protected final String string;
|
||||
|
||||
public CharArrayCharSequence(char... chars) {
|
||||
string = new String(chars);
|
||||
}
|
||||
}
|
||||
+6
@@ -41032,6 +41032,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt45187.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt46092.kt")
|
||||
public void testKt46092() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt46092.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt581.kt")
|
||||
public void testKt581() throws Exception {
|
||||
|
||||
+6
@@ -41056,6 +41056,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/vararg/kt45187.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt46092.kt")
|
||||
public void testKt46092() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt46092.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt581.kt")
|
||||
public void testKt581() throws Exception {
|
||||
|
||||
+5
@@ -33008,6 +33008,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/vararg/kt45187.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt46092.kt")
|
||||
public void testKt46092() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt46092.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt581.kt")
|
||||
public void testKt581() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/kt581.kt");
|
||||
|
||||
Reference in New Issue
Block a user