Fix for KT-9788: AssertionError from back-end when we read field from inline function
#KT-9788 Fixed
This commit is contained in:
@@ -2014,7 +2014,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class JavaClass {
|
||||
|
||||
protected String FIELD = "OK";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
import JavaClass
|
||||
|
||||
class B : JavaClass() {
|
||||
inline fun bar() = FIELD
|
||||
}
|
||||
|
||||
fun box() = B().bar()
|
||||
+6
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user