IR KT-47483 handle 'Nothing' in array constructor call
This commit is contained in:
+6
@@ -1083,6 +1083,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/arrays/kt45410.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47499.kt")
|
||||
public void testKt47499() throws Exception {
|
||||
|
||||
+9
-5
@@ -19,10 +19,7 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.types.IrTypeProjection
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.constructedClass
|
||||
import org.jetbrains.kotlin.ir.util.constructors
|
||||
import org.jetbrains.kotlin.ir.util.functions
|
||||
@@ -69,6 +66,10 @@ private class ArrayConstructorTransformer(
|
||||
// (and similar for primitive arrays)
|
||||
val size = expression.getValueArgument(0)!!.transform(this, null)
|
||||
val invokable = expression.getValueArgument(1)!!.transform(this, null)
|
||||
if (invokable.type.isNothing()) {
|
||||
// Expressions of type 'Nothing' don't terminate.
|
||||
return invokable
|
||||
}
|
||||
val scope = (currentScope ?: createScope(container)).scope
|
||||
return context.createIrBuilder(scope.scopeOwnerSymbol).irBlock(expression.startOffset, expression.endOffset) {
|
||||
val index = createTmpVariable(irInt(0), isMutable = true)
|
||||
@@ -89,7 +90,10 @@ private class ArrayConstructorTransformer(
|
||||
+irCall(result.type.getClass()!!.functions.single { it.name == OperatorNameConventions.SET }).apply {
|
||||
dispatchReceiver = irGet(result)
|
||||
putValueArgument(0, irGet(tempIndex))
|
||||
putValueArgument(1, generator.inline(parent, listOf(tempIndex)).patchDeclarationParents(scope.getLocalDeclarationParent()))
|
||||
val inlined = generator
|
||||
.inline(parent, listOf(tempIndex))
|
||||
.patchDeclarationParents(scope.getLocalDeclarationParent())
|
||||
putValueArgument(1, inlined)
|
||||
}
|
||||
val inc = index.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INC }
|
||||
+irSet(index.symbol, irCallOp(inc.symbol, index.type, irGet(index)))
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box(): String {
|
||||
val test: Array<Int> = Array(42, return "OK")
|
||||
}
|
||||
+6
@@ -1005,6 +1005,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt45410.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47499.kt")
|
||||
public void testKt47499() throws Exception {
|
||||
|
||||
+6
@@ -1083,6 +1083,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/arrays/kt45410.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47499.kt")
|
||||
public void testKt47499() throws Exception {
|
||||
|
||||
+5
@@ -884,6 +884,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/arrays/kt45410.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47499.kt")
|
||||
public void testKt47499() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47499.kt");
|
||||
|
||||
+6
@@ -537,6 +537,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt503.kt")
|
||||
public void testKt503() throws Exception {
|
||||
|
||||
Generated
+6
@@ -319,6 +319,12 @@ public class JsLegacyPrimitiveArraysBoxTestGenerated extends AbstractJsLegacyPri
|
||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt503.kt")
|
||||
public void testKt503() throws Exception {
|
||||
|
||||
+6
@@ -579,6 +579,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt503.kt")
|
||||
public void testKt503() throws Exception {
|
||||
|
||||
+5
@@ -529,6 +529,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt503.kt")
|
||||
public void testKt503() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt503.kt");
|
||||
|
||||
+6
@@ -598,6 +598,12 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt47483.kt")
|
||||
public void testKt47483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/kt47483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt503.kt")
|
||||
public void testKt503() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user