Fix companion method access from inline class
#KT-27025
This commit is contained in:
@@ -253,10 +253,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (!(myClass instanceof KtClass)) return;
|
||||
if (!descriptor.isInline()) return;
|
||||
|
||||
CodegenContext parentContext = context.getParentContext();
|
||||
assert parentContext != null : "Parent context of inline class declaration should not be null";
|
||||
|
||||
ClassContext erasedInlineClassContext = parentContext.intoWrapperForErasedInlineClass(descriptor, state);
|
||||
ClassContext erasedInlineClassContext = context.intoWrapperForErasedInlineClass(descriptor, state);
|
||||
new ErasedInlineClassBodyCodegen((KtClass) myClass, erasedInlineClassContext, v, state, this).generate();
|
||||
}
|
||||
|
||||
@@ -270,7 +267,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (inlinedValue == null) return;
|
||||
|
||||
Type valueType = typeMapper.mapType(inlinedValue.getType());
|
||||
SimpleFunctionDescriptor functionDescriptor = InlineClassDescriptorResolver.INSTANCE.createUnboxFunctionDescriptor(this.descriptor);
|
||||
SimpleFunctionDescriptor functionDescriptor = InlineClassDescriptorResolver.createUnboxFunctionDescriptor(this.descriptor);
|
||||
assert functionDescriptor != null : "FunctionDescriptor for unbox method should be not null during codegen";
|
||||
|
||||
functionCodegen.generateMethod(
|
||||
|
||||
@@ -393,12 +393,16 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
public CodegenContext findParentContextWithDescriptor(DeclarationDescriptor descriptor) {
|
||||
CodegenContext c = this;
|
||||
while (c != null) {
|
||||
if (c.getContextDescriptor() == descriptor) break;
|
||||
if (!c.shouldSkipThisContextInHierarchy() && c.getContextDescriptor() == descriptor) break;
|
||||
c = c.getParentContext();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
private boolean shouldSkipThisContextInHierarchy() {
|
||||
return getContextKind() == OwnerKind.ERASED_INLINE_CLASS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PropertyDescriptor getPropertyAccessor(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
|
||||
Reference in New Issue
Block a user