JVM backend test for local returns
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
fun box(): String {
|
||||||
|
val a = 1
|
||||||
|
val explicitlyReturned = run1 @f{(): String ->
|
||||||
|
if (a > 0)
|
||||||
|
return@f "OK"
|
||||||
|
else "Fail 1"
|
||||||
|
}
|
||||||
|
if (explicitlyReturned != "OK") return explicitlyReturned
|
||||||
|
|
||||||
|
val implicitlyReturned = run1 @f{(): String ->
|
||||||
|
if (a < 0)
|
||||||
|
return@f "Fail 2"
|
||||||
|
else "OK"
|
||||||
|
}
|
||||||
|
if (implicitlyReturned != "OK") return implicitlyReturned
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun run1<T>(f: () -> T): T { return f() }
|
||||||
@@ -1199,6 +1199,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/closures/localFunctionInInitializer.kt");
|
doTest("compiler/testData/codegen/box/closures/localFunctionInInitializer.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("localReturn.kt")
|
||||||
|
public void testLocalReturn() throws Exception {
|
||||||
|
doTest("compiler/testData/codegen/box/closures/localReturn.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("recursiveClosure.kt")
|
@TestMetadata("recursiveClosure.kt")
|
||||||
public void testRecursiveClosure() throws Exception {
|
public void testRecursiveClosure() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/closures/recursiveClosure.kt");
|
doTest("compiler/testData/codegen/box/closures/recursiveClosure.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user