JVM_IR: Do not generate parameter annotations for continuation constructors
The idea is the same as in case of anonymous objects: they are created only from Kotlin code, so we are sure, that the parameters are valid. Also, the inliner complains on their transformations.
This commit is contained in:
@@ -131,12 +131,6 @@ class MethodInliner(
|
||||
|
||||
processReturns(resultNode, returnLabelOwner, remapReturn, end)
|
||||
//flush transformed node to output
|
||||
// TODO: HACK resultNode's invisibleParameterAnnotations' size is greater than adapter's
|
||||
if (resultNode.name == "<init>" && resultNode.desc.contains("Lkotlin/coroutines/Continuation;") &&
|
||||
inliningContext.root.state.isIrBackend
|
||||
) {
|
||||
resultNode.invisibleParameterAnnotations = null
|
||||
}
|
||||
resultNode.accept(SkipMaxAndEndVisitor(adapter))
|
||||
|
||||
sourceMapper.endMapping()
|
||||
|
||||
+10
-5
@@ -68,11 +68,8 @@ open class FunctionCodegen(
|
||||
)
|
||||
}
|
||||
|
||||
// Since the only arguments to anonymous object constructors are captured variables and complex
|
||||
// super constructor arguments, there shouldn't be any annotations on them other than @NonNull,
|
||||
// and those are meaningless on synthetic parameters. (Also, the inliner cannot handle them and
|
||||
// will throw an exception if we generate any.)
|
||||
if (irFunction !is IrConstructor || !irFunction.parentAsClass.isAnonymousObject) {
|
||||
|
||||
if (irFunction !is IrConstructor || !irFunction.parentAsClass.shouldNotGenerateConstructorParameterAnnotations()) {
|
||||
generateParameterAnnotations(functionView, methodVisitor, signature, classCodegen, context)
|
||||
}
|
||||
|
||||
@@ -110,6 +107,14 @@ open class FunctionCodegen(
|
||||
return signature
|
||||
}
|
||||
|
||||
// Since the only arguments to anonymous object constructors are captured variables and complex
|
||||
// super constructor arguments, there shouldn't be any annotations on them other than @NonNull,
|
||||
// and those are meaningless on synthetic parameters. (Also, the inliner cannot handle them and
|
||||
// will throw an exception if we generate any.)
|
||||
// The same applies for continuations.
|
||||
private fun IrClass.shouldNotGenerateConstructorParameterAnnotations() =
|
||||
isAnonymousObject || origin == JvmLoweredDeclarationOrigin.CONTINUATION_CLASS || origin == JvmLoweredDeclarationOrigin.SUSPEND_LAMBDA
|
||||
|
||||
private fun psiElement(): KtElement =
|
||||
if (irFunction.isSuspend) irFunction.symbol.descriptor.psiElement as KtElement
|
||||
else context.suspendLambdaToOriginalFunctionMap[irFunction.parentAsClass.attributeOwnerId]!!.symbol.descriptor.psiElement as KtElement
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ final class LambdaWithLongReceiverKt$box$1$1 {
|
||||
private field label: int
|
||||
inner class LambdaWithLongReceiverKt$box$1
|
||||
inner class LambdaWithLongReceiverKt$box$1$1
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final method invoke(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
@@ -19,7 +19,7 @@ final class LambdaWithLongReceiverKt$box$1 {
|
||||
private field label: int
|
||||
inner class LambdaWithLongReceiverKt$box$1
|
||||
inner class LambdaWithLongReceiverKt$box$1$1
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final method invoke(p0: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
@@ -29,7 +29,7 @@ final class LambdaWithLongReceiverKt$box$1 {
|
||||
final class LambdaWithLongReceiverKt$call$1 {
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ final class LambdaWithMultipleParametersKt$box$1$1 {
|
||||
private field label: int
|
||||
inner class LambdaWithMultipleParametersKt$box$1
|
||||
inner class LambdaWithMultipleParametersKt$box$1$1
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final method invoke(p0: java.lang.Object, p1: java.lang.Object, p2: java.lang.Object, p3: java.lang.Object, p4: java.lang.Object, p5: java.lang.Object, p6: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
@@ -23,7 +23,7 @@ final class LambdaWithMultipleParametersKt$box$1 {
|
||||
private field label: int
|
||||
inner class LambdaWithMultipleParametersKt$box$1
|
||||
inner class LambdaWithMultipleParametersKt$box$1$1
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final method invoke(p0: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
@@ -33,7 +33,7 @@ final class LambdaWithMultipleParametersKt$box$1 {
|
||||
final class LambdaWithMultipleParametersKt$call$1 {
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FULL_JDK
|
||||
// COMMON_COROUTINES_TEST
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_COROUTINES
|
||||
// WITH_RUNTIME
|
||||
|
||||
Vendored
+3
-3
@@ -6,7 +6,7 @@ final class InlineWithoutStateMachineKt$box$1 {
|
||||
field L$1: java.lang.Object
|
||||
private field label: int
|
||||
inner class InlineWithoutStateMachineKt$box$1
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.internal.Ref$ObjectRef, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final method invoke(p0: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
@@ -19,7 +19,7 @@ final class InlineWithoutStateMachineKt$complexSuspend$1 {
|
||||
field L$1: java.lang.Object
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ final class InlineWithoutStateMachineKt$suspendHere$1 {
|
||||
field L$0: java.lang.Object
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -13,7 +13,7 @@ public interface flow/FlowCollector {
|
||||
final class flow/InnerObjectRetransformationKt$box$1 {
|
||||
private field label: int
|
||||
inner class flow/InnerObjectRetransformationKt$box$1
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
|
||||
public final method invoke(p0: java.lang.Object): java.lang.Object
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
@@ -72,7 +72,7 @@ final class flow/InnerObjectRetransformationKt$check$1 {
|
||||
field L$0: java.lang.Object
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
public method <init>(@org.jetbrains.annotations.Nullable p0: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ final class flow/InnerObjectRetransformationKt$collect$2$emit$1 {
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
private field this$0: flow.InnerObjectRetransformationKt$collect$2
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: flow.InnerObjectRetransformationKt$collect$2, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: flow.InnerObjectRetransformationKt$collect$2, p1: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ final class flow/InnerObjectRetransformationKt$flow$1$collect$1 {
|
||||
field label: int
|
||||
@org.jetbrains.annotations.NotNull field result: java.lang.Object
|
||||
private field this$0: flow.InnerObjectRetransformationKt$flow$1
|
||||
public method <init>(@org.jetbrains.annotations.NotNull p0: flow.InnerObjectRetransformationKt$flow$1, @org.jetbrains.annotations.Nullable p1: kotlin.coroutines.Continuation): void
|
||||
public method <init>(p0: flow.InnerObjectRetransformationKt$flow$1, p1: kotlin.coroutines.Continuation): void
|
||||
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user