Kapt+JVM_IR: support error types in suspend functions

JVM IR generates the continuation parameter with the name `$completion`
instead of `continuation`.
This commit is contained in:
Alexander Udalov
2023-01-06 21:39:29 +01:00
parent 4f2551497d
commit 690fe7ac9a
3 changed files with 15 additions and 2 deletions
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.base.kapt3.KaptFlag
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.coroutines.CONTINUATION_PARAMETER_NAME
import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
@@ -1122,7 +1123,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
val containingCallable = descriptor.containingDeclaration
return containingCallable.valueParameters.lastOrNull() == descriptor
&& descriptor.name == CONTINUATION_PARAMETER_NAME
&& (descriptor.name == CONTINUATION_PARAMETER_NAME || descriptor.name.asString() == SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME)
&& descriptor.source == SourceElement.NO_SOURCE
&& descriptor.type.constructor.declarationDescriptor?.fqNameSafe == StandardNames.CONTINUATION_INTERFACE_FQ_NAME
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// CORRECT_ERROR_TYPES
// NO_VALIDATION
// WITH_STDLIB
@@ -0,0 +1,13 @@
@kotlin.Metadata()
public final class Foo {
public Foo() {
super();
}
@org.jetbrains.annotations.Nullable()
public final java.lang.Object a(@org.jetbrains.annotations.NotNull()
kotlin.coroutines.Continuation<ABC> $completion) {
return null;
}
}