Fix isInitialized for companion lateinit properties

Instead of trying to access a missing field `Foo.foo`, call the
synthetic accessor `Foo.access$getFoo$cp` which, as per previous commit,
no longer contains the lateinit assertion

 #KT-21862 Fixed
This commit is contained in:
Alexander Udalov
2018-11-19 19:32:34 +01:00
parent 43413fcc44
commit 8c74312cf6
7 changed files with 77 additions and 2 deletions
@@ -2084,10 +2084,19 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
couldUseDirectAccessToProperty(propertyDescriptor, false, isDelegatedProperty, context, state.getShouldInlineConstVals());
if (fieldAccessorKind == AccessorKind.LATEINIT_INTRINSIC) {
skipPropertyAccessors = !isPrivateProperty || context.getClassOrPackageParentContext() == backingFieldContext;
skipPropertyAccessors =
(!isPrivateProperty || context.getClassOrPackageParentContext() == backingFieldContext) &&
!isBackingFieldMovedFromCompanion;
if (!skipPropertyAccessors) {
propertyDescriptor = backingFieldContext.getAccessor(propertyDescriptor, fieldAccessorKind, delegateType, superCallTarget);
if (isBackingFieldMovedFromCompanion && context.getContextDescriptor() instanceof AccessorForPropertyBackingField) {
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getParentContext()
.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
}
else {
propertyDescriptor =
backingFieldContext.getAccessor(propertyDescriptor, fieldAccessorKind, delegateType, superCallTarget);
}
}
ownerDescriptor = propertyDescriptor;
}