IR: bugfix in KotlinNothingValueExceptionLowering
This commit is contained in:
Generated
+5
@@ -17403,6 +17403,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
+2
-2
@@ -43,12 +43,12 @@ class KotlinNothingValueExceptionLowering(val backendContext: CommonBackendConte
|
|||||||
// (although doing so by subverting the type system).
|
// (although doing so by subverting the type system).
|
||||||
backendContext.createIrBuilder(parent, expression.startOffset, expression.endOffset).run {
|
backendContext.createIrBuilder(parent, expression.startOffset, expression.endOffset).run {
|
||||||
irBlock(expression, null, context.irBuiltIns.nothingType) {
|
irBlock(expression, null, context.irBuiltIns.nothingType) {
|
||||||
+changeTypeToUnit(expression)
|
+super.visitCall(changeTypeToUnit(expression))
|
||||||
+irCall(backendContext.ir.symbols.ThrowKotlinNothingValueException)
|
+irCall(backendContext.ir.symbols.ThrowKotlinNothingValueException)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
expression
|
super.visitCall(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeTypeToUnit(call: IrCall): IrCall =
|
private fun changeTypeToUnit(call: IrCall): IrCall =
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun nestedNothing(s: String) =
|
||||||
|
"" + if (s == "OK") s else barf()
|
||||||
|
|
||||||
|
fun barf(): Nothing = throw NullPointerException()
|
||||||
|
|
||||||
|
fun box() = nestedNothing("OK")
|
||||||
+5
@@ -18618,6 +18618,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
+5
@@ -18618,6 +18618,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
+5
@@ -17403,6 +17403,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
Generated
+5
@@ -14018,6 +14018,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
+5
@@ -14083,6 +14083,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/nothingValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inNestedCall.kt")
|
||||||
|
public void testInNestedCall() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/nothingValue/inNestedCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nothingValueException.kt")
|
@TestMetadata("nothingValueException.kt")
|
||||||
public void testNothingValueException() throws Exception {
|
public void testNothingValueException() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
runTest("compiler/testData/codegen/box/nothingValue/nothingValueException.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user