JVM_IR: fix name of received field for suspend lambdas
$ at the start caused AnonymousObjectTransformer to skip the field.
This commit is contained in:
committed by
Ilmir Usmanov
parent
068d3f4beb
commit
d4b0151f51
+2
-1
@@ -110,7 +110,8 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
|||||||
|
|
||||||
val receiverField = info.function.extensionReceiverParameter?.let {
|
val receiverField = info.function.extensionReceiverParameter?.let {
|
||||||
assert(info.arity != 0)
|
assert(info.arity != 0)
|
||||||
addField("\$p", it.type)
|
// Do not put '$' at the start, to avoid being caught by inlineCodegenUtils.isCapturedFieldName()
|
||||||
|
addField("p\$", it.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
val parametersFields = info.function.valueParameters.map { addField(it.name.asString(), it.type) }
|
val parametersFields = info.function.valueParameters.map { addField(it.name.asString(), it.type) }
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
@kotlin.coroutines.jvm.internal.DebugMetadata
|
@kotlin.coroutines.jvm.internal.DebugMetadata
|
||||||
@kotlin.Metadata
|
@kotlin.Metadata
|
||||||
final class LambdaWithLongReceiverKt$box$1$1 {
|
final class LambdaWithLongReceiverKt$box$1$1 {
|
||||||
private field $p: long
|
|
||||||
private field label: int
|
private field label: int
|
||||||
|
private field p$: long
|
||||||
inner class LambdaWithLongReceiverKt$box$1
|
inner class LambdaWithLongReceiverKt$box$1
|
||||||
inner class LambdaWithLongReceiverKt$box$1$1
|
inner class LambdaWithLongReceiverKt$box$1$1
|
||||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _Example_
|
||||||
|
* The following will print `1`, `2` and `3` when executed:
|
||||||
|
* ```
|
||||||
|
* arrayOf(1, 2, 3, 4, 5)
|
||||||
|
* .iterator()
|
||||||
|
* .stopAfter { it == 3 }
|
||||||
|
* .forEach(::println)
|
||||||
|
* ```
|
||||||
|
* @return an iterator, which stops [this] Iterator after first element for which [predicate] returns `true`
|
||||||
|
*/
|
||||||
|
inline fun <T> Iterator<T>.stopAfter(crossinline predicate: (T) -> Boolean): Iterator<T> = iterator {
|
||||||
|
for (element in this@stopAfter) {
|
||||||
|
yield(element)
|
||||||
|
if (predicate(element)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() =
|
||||||
|
listOf("OK", "fail").iterator().stopAfter { it == "OK" }.next()
|
||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+5
@@ -6539,6 +6539,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_2() throws Exception {
|
public void testSuspendCallsInArguments_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
+5
@@ -6539,6 +6539,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_2() throws Exception {
|
public void testSuspendCallsInArguments_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
+5
@@ -6179,6 +6179,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_3() throws Exception {
|
public void testSuspendCallsInArguments_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
||||||
|
|||||||
+5
@@ -6179,6 +6179,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_3() throws Exception {
|
public void testSuspendCallsInArguments_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
||||||
|
|||||||
Generated
+5
@@ -5269,6 +5269,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_3() throws Exception {
|
public void testSuspendCallsInArguments_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines");
|
||||||
|
|||||||
+5
@@ -5589,6 +5589,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stopAfter.kt")
|
||||||
|
public void testStopAfter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/stopAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendCallsInArguments.kt")
|
@TestMetadata("suspendCallsInArguments.kt")
|
||||||
public void testSuspendCallsInArguments_1_2() throws Exception {
|
public void testSuspendCallsInArguments_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
Reference in New Issue
Block a user