diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 336ab6a0d6d..5c91fc84631 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -30591,6 +30591,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); 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 932db9ad6f4..5e662b16fd9 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 @@ -576,7 +576,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val symbolOwner = owner val declarationRaw = symbolOwner as IrDeclarationWithVisibility val declaration = - (declarationRaw as? IrSimpleFunction)?.resolveFakeOverride() ?: declarationRaw + (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 diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt new file mode 100644 index 00000000000..d029bbeec6e --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt @@ -0,0 +1,17 @@ +// FILE: 1.kt +import a.* + +abstract class B : A() { + fun g() = { f() }() +} + +fun box() = object : B() { + override fun f(): String = "OK" +}.g() + +// FILE: 2.kt +package a + +abstract class A { + protected abstract fun f(): String +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 79397078176..e3b140e4415 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -32357,6 +32357,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 38baaf118ee..b3644774bb9 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29991,6 +29991,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 67649216f94..a94382d65bf 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -30591,6 +30591,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index cf9b6414938..214186276e6 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -24872,6 +24872,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 0114790def5..3bfddb0d755 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -24872,6 +24872,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index bedcd0c50d9..b15321ec5a8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24887,6 +24887,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + @TestMetadata("accessorForAbstractProtected.kt") + public void testAccessorForAbstractProtected() throws Exception { + runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForAbstractProtected.kt"); + } + @TestMetadata("accessorForGenericConstructor.kt") public void testAccessorForGenericConstructor() throws Exception { runTest("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt");