Validate label value of coroutine in case of no suspension points
#KT-14718 Fixed
This commit is contained in:
-2
@@ -74,8 +74,6 @@ class CoroutineTransformerMethodVisitor(
|
|||||||
// Add global exception handler
|
// Add global exception handler
|
||||||
processHandleExceptionCall(methodNode)
|
processHandleExceptionCall(methodNode)
|
||||||
|
|
||||||
if (suspensionPoints.isEmpty()) return
|
|
||||||
|
|
||||||
// Spill stack to variables before suspension points, try/catch blocks
|
// Spill stack to variables before suspension points, try/catch blocks
|
||||||
FixStackWithLabelNormalizationMethodTransformer().transform(classBuilder.thisName, methodNode)
|
FixStackWithLabelNormalizationMethodTransformer().transform(classBuilder.thisName, methodNode)
|
||||||
|
|
||||||
|
|||||||
+21
-1
@@ -35,7 +35,27 @@ fun box(): String {
|
|||||||
return "fail 3"
|
return "fail 3"
|
||||||
} catch (e: java.lang.IllegalStateException) {
|
} catch (e: java.lang.IllegalStateException) {
|
||||||
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 4: ${e.message!!}"
|
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 4: ${e.message!!}"
|
||||||
return "OK"
|
}
|
||||||
|
|
||||||
|
var result = "OK"
|
||||||
|
|
||||||
|
try {
|
||||||
|
builder1 {
|
||||||
|
result = "fail 5"
|
||||||
|
}
|
||||||
|
return "fail 6"
|
||||||
|
} catch (e: java.lang.IllegalStateException) {
|
||||||
|
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 7: ${e.message!!}"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
builder2 {
|
||||||
|
result = "fail 8"
|
||||||
|
}
|
||||||
|
return "fail 9"
|
||||||
|
} catch (e: java.lang.IllegalStateException) {
|
||||||
|
if (e.message != "call to 'resume' before 'invoke' with coroutine") return "fail 10: ${e.message!!}"
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
return "fail"
|
return "fail"
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
class Controller {
|
||||||
|
var res = 0
|
||||||
|
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
|
||||||
|
res = x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Int {
|
||||||
|
val controller = Controller()
|
||||||
|
c(controller).resume(Unit)
|
||||||
|
|
||||||
|
return controller.res
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var result = ""
|
||||||
|
|
||||||
|
val handledResult = builder {
|
||||||
|
result = "OK"
|
||||||
|
56
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handledResult != 56) return "fail 1: $handledResult"
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
+6
@@ -4573,6 +4573,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noSuspensionPoints.kt")
|
||||||
|
public void testNoSuspensionPoints() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nonLocalReturnFromInlineLambda.kt")
|
@TestMetadata("nonLocalReturnFromInlineLambda.kt")
|
||||||
public void testNonLocalReturnFromInlineLambda() throws Exception {
|
public void testNonLocalReturnFromInlineLambda() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt");
|
||||||
|
|||||||
@@ -4573,6 +4573,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noSuspensionPoints.kt")
|
||||||
|
public void testNoSuspensionPoints() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nonLocalReturnFromInlineLambda.kt")
|
@TestMetadata("nonLocalReturnFromInlineLambda.kt")
|
||||||
public void testNonLocalReturnFromInlineLambda() throws Exception {
|
public void testNonLocalReturnFromInlineLambda() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user