From 1a36ee2110a559b5bbd3940f060ad3506c9fe17e Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 24 Feb 2021 15:22:49 +0300 Subject: [PATCH] IR: Postpone computing real fake overrides at SyntheticAccessorLowering --- .../backend/jvm/lower/SyntheticAccessorLowering.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt index 96e920d1173..e73690da85e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt @@ -632,17 +632,15 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val symbolOwner = owner val declarationRaw = symbolOwner as IrDeclarationWithVisibility - val declaration = - (declarationRaw as? IrSimpleFunction)?.resolveFakeOverride(allowAbstract = true) ?: declarationRaw // There is never a problem with visibility of inline functions, as those don't end up as Java entities - if (declaration is IrFunction && declaration.isInline) return true + if (declarationRaw is IrFunction && declarationRaw.isInline) return true // Enum entry constructors are generated as package-private and are accessed only from corresponding enum class - if (declaration is IrConstructor && declaration.constructedClass.isEnumEntry) return true + if (declarationRaw is IrConstructor && declarationRaw.constructedClass.isEnumEntry) return true // `internal` maps to public and requires no accessor. - if (!withSuper && !declaration.visibility.isPrivate && !declaration.visibility.isProtected) return true + if (!withSuper && !declarationRaw.visibility.isPrivate && !declarationRaw.visibility.isProtected) return true // `toArray` is always accessible cause mapped to public functions if (symbolOwner is IrSimpleFunction && (symbolOwner.isNonGenericToArray() || symbolOwner.isGenericToArray(context))) { @@ -655,6 +653,9 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle if (symbolOwner is IrConstructor && symbolOwner.parentClassOrNull?.isEnumEntry == true) return true + val declaration = + (declarationRaw as? IrSimpleFunction)?.resolveFakeOverride(allowAbstract = true) ?: declarationRaw + // If local variables are accessible by Kotlin rules, they also are by Java rules. val ownerClass = declaration.parent as? IrClass ?: return true