diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 47787f36f0e..ebb2137513f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2014,7 +2014,6 @@ public class ExpressionCodegen extends KtVisitor impleme boolean directToField = isSyntheticField && contextKind() != OwnerKind.DEFAULT_IMPLS; ClassDescriptor superCallTarget = resolvedCall == null ? null : getSuperCallTarget(resolvedCall.getCall()); - propertyDescriptor = context.accessibleDescriptor(propertyDescriptor, superCallTarget); if (directToField) { receiver = StackValue.receiverWithoutReceiverArgument(receiver); @@ -2201,6 +2200,7 @@ public class ExpressionCodegen extends KtVisitor impleme DeclarationDescriptor ownerDescriptor = containingDeclaration; boolean skipPropertyAccessors; + PropertyDescriptor originalPropertyDescriptor = DescriptorUtils.unwrapFakeOverride(propertyDescriptor); if (fieldAccessorKind != FieldAccessorKind.NORMAL) { int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty); skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || skipAccessorsForPrivateFieldInOuterClass; @@ -2259,7 +2259,7 @@ public class ExpressionCodegen extends KtVisitor impleme if (isExtensionProperty && !isDelegatedProperty) { fieldName = null; } - else if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) { + else if (originalPropertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) { assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext"; fieldName = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java index bdff9c99bbf..1613a34f69a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java @@ -139,7 +139,7 @@ public class JvmCodegenUtil { if (JetTypeMapper.isAccessor(property)) return false; // Inline functions can't use direct access because a field may not be visible at the call site - if (context.isInlineFunction() && !Visibilities.isPrivate(property.getVisibility())) { + if (context.isInlineFunction()) { return false; } diff --git a/compiler/testData/codegen/boxWithJava/protectedInInline/JavaClass.java b/compiler/testData/codegen/boxWithJava/protectedInInline/JavaClass.java new file mode 100644 index 00000000000..346dff3f2f0 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/protectedInInline/JavaClass.java @@ -0,0 +1,5 @@ +public class JavaClass { + + protected String FIELD = "OK"; + +} diff --git a/compiler/testData/codegen/boxWithJava/protectedInInline/Kotlin.kt b/compiler/testData/codegen/boxWithJava/protectedInInline/Kotlin.kt new file mode 100644 index 00000000000..c79521acae2 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/protectedInInline/Kotlin.kt @@ -0,0 +1,9 @@ +package test + +import JavaClass + +class B : JavaClass() { + inline fun bar() = FIELD +} + +fun box() = B().bar() \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index bf01756092c..41837f1bd6c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -101,6 +101,12 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege doTestWithJava(fileName); } + @TestMetadata("protectedInInline") + public void testProtectedInInline() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/protectedInInline/"); + doTestWithJava(fileName); + } + @TestMetadata("compiler/testData/codegen/boxWithJava/annotatedFileClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)