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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user