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:
+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
|
||||
|
||||
Reference in New Issue
Block a user