[Wasm] Fix invalid boxing for non-primitive typed vararg
This commit is contained in:
+6
@@ -50733,6 +50733,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+9
-1
@@ -114,7 +114,7 @@ abstract class AbstractValueUsageLowering(val context: JsCommonBackendContext) :
|
||||
if (icUtils.isTypeInlined(element.type) && !icUtils.isTypeInlined(expression.type) && !expression.type.isPrimitiveArray())
|
||||
irBuiltIns.anyNType
|
||||
else
|
||||
expression.varargElementType
|
||||
if (!expression.type.isPrimitiveArray()) irBuiltIns.anyNType else expression.varargElementType
|
||||
)
|
||||
}
|
||||
|
||||
@@ -136,6 +136,14 @@ class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsag
|
||||
return res
|
||||
}
|
||||
|
||||
override fun visitFunction(declaration: IrFunction): IrStatement {
|
||||
return super.visitFunction(declaration)
|
||||
}
|
||||
|
||||
override fun visitVararg(expression: IrVararg): IrExpression {
|
||||
return super.visitVararg(expression)
|
||||
}
|
||||
|
||||
override fun IrExpression.useAsResult(enclosing: IrExpression): IrExpression {
|
||||
if (processingReturnStack.lastOrNull()?.value == enclosing && enclosing is IrReturnableBlock) {
|
||||
return useReturnableExpressionAsType(enclosing.type)
|
||||
|
||||
+3
-1
@@ -36,7 +36,9 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme
|
||||
private val builtIns = context.irBuiltIns
|
||||
|
||||
private lateinit var builder: DeclarationIrBuilder
|
||||
|
||||
override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement {
|
||||
return super.visitSimpleFunction(declaration)
|
||||
}
|
||||
override fun visitTypeOperator(expression: IrTypeOperatorCall): IrExpression {
|
||||
super.visitTypeOperator(expression)
|
||||
builder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol).at(expression)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
fun <T> anyVararg(vararg x: T): Boolean = x[0] == 123f
|
||||
|
||||
fun boxingNullablePrimitiveToAny(x: Float?): Boolean {
|
||||
if (x !== null) {
|
||||
return anyVararg(x)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun boxingPrimitiveToAny(x: Float): Boolean =
|
||||
anyVararg(x)
|
||||
|
||||
fun primitiveVararg(vararg x: Float): Boolean = x[0] == 123f
|
||||
|
||||
fun unboxingNullablePrimitiveToPrimitive(x: Float?): Boolean {
|
||||
if (x !== null) {
|
||||
return primitiveVararg(x)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun noBoxingPrimitiveToPrimitive(x: Float): Boolean =
|
||||
primitiveVararg(x)
|
||||
|
||||
inline class InlineClass(val x: Float)
|
||||
|
||||
fun <T : InlineClass> valueClassAnyVararg(vararg x: T): Boolean = x[0].x == 123f
|
||||
|
||||
fun boxingInlineClassToAny(x: InlineClass): Boolean =
|
||||
valueClassAnyVararg(x)
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (!boxingNullablePrimitiveToAny(123f)) return "Fail1"
|
||||
if (!boxingPrimitiveToAny(123f)) return "Fail2"
|
||||
if (!unboxingNullablePrimitiveToPrimitive(123f)) return "Fail3"
|
||||
if (!noBoxingPrimitiveToPrimitive(123f)) return "Fail4"
|
||||
if (!boxingInlineClassToAny(InlineClass(123f))) return "Fail5"
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -48741,6 +48741,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+6
@@ -50733,6 +50733,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+5
@@ -39600,6 +39600,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/vararg/assigningArrayToVarargInAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt");
|
||||
|
||||
+6
@@ -36227,6 +36227,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/vararg"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+6
@@ -36407,6 +36407,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/vararg"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+6
@@ -36407,6 +36407,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/vararg"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
+5
@@ -32610,6 +32610,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/vararg"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt");
|
||||
|
||||
+6
@@ -39552,6 +39552,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/vararg"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("boxingArgumentsForVararg.kt")
|
||||
public void testBoxingArgumentsForVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/vararg/boxingArgumentsForVararg.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doNotCopyImmediatelyCreatedArrays.kt")
|
||||
public void testDoNotCopyImmediatelyCreatedArrays() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user