From 50bbf4f269b2f854cb91cdb4d17ffe926f47d67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Tue, 5 Jan 2021 13:23:31 +0100 Subject: [PATCH] JVM IR: Remove special descriptor origin for lambdas. This was a hack to allow plugins to identify anonymous classes in inline function scope. However, this stopped working for anonymous objects with the introduction of IrBasedDescriptors and became redundant with the public ABI bit in the Kotlin Metadata annotation. --- .../kotlin/backend/jvm/codegen/ClassCodegen.kt | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt index 5933fab5b97..04cb8163ea8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConst import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol @@ -484,20 +483,10 @@ class ClassCodegen private constructor( private val IrDeclaration.descriptorOrigin: JvmDeclarationOrigin get() { val psiElement = PsiSourceManager.findPsiElement(this) - // For declarations inside lambdas, produce a descriptor which refers back to the original function. - // This is needed for plugins which check for lambdas inside of inline functions using the descriptor - // contained in JvmDeclarationOrigin. This matches the behavior of the JVM backend. - // TODO: this is really not very useful, as this does nothing for other anonymous objects. - val isLambda = irClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL || - irClass.origin == JvmLoweredDeclarationOrigin.SUSPEND_LAMBDA - val descriptor = if (isLambda) - irClass.attributeOwnerId.safeAs()?.symbol?.owner?.toIrBasedDescriptor() ?: toIrBasedDescriptor() - else - toIrBasedDescriptor() return if (origin == IrDeclarationOrigin.FILE_CLASS) - JvmDeclarationOrigin(JvmDeclarationOriginKind.PACKAGE_PART, psiElement, descriptor) + JvmDeclarationOrigin(JvmDeclarationOriginKind.PACKAGE_PART, psiElement, toIrBasedDescriptor()) else - OtherOrigin(psiElement, descriptor) + OtherOrigin(psiElement, toIrBasedDescriptor()) } companion object {