Fix companion method access from inline class

#KT-27025
This commit is contained in:
Dmitry Petrov
2018-09-21 15:46:48 +03:00
parent 1869ed09bc
commit f9a419f940
8 changed files with 44 additions and 6 deletions
@@ -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,