Support generating computable properties inside inline classes

This commit is contained in:
Mikhail Zarechenskiy
2018-02-06 16:52:52 +03:00
parent 47aeeb36e4
commit 30c79ffadc
10 changed files with 88 additions and 3 deletions
@@ -117,7 +117,7 @@ public class CallReceiver extends StackValue {
// all the needed information, for example there's no way to find out whether or not a smart cast was applied to the receiver.
if (container instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) container;
return new AsmTypeAndKotlinType(typeMapper.mapClass(classDescriptor), classDescriptor.getDefaultType());
return new AsmTypeAndKotlinType(typeMapper.mapType(classDescriptor), classDescriptor.getDefaultType());
}
KotlinType dispatchReceiverType = dispatchReceiver.getReturnType();
@@ -243,7 +243,8 @@ public class FunctionCodegen {
isClass(containingDeclaration) &&
((ClassDescriptor) containingDeclaration).isInline() &&
contextKind != OwnerKind.ERASED_INLINE_CLASS &&
functionDescriptor instanceof SimpleFunctionDescriptor &&
!(functionDescriptor instanceof ConstructorDescriptor) &&
!KotlinTypeMapper.isAccessor(functionDescriptor) &&
origin.getOriginKind() != JvmDeclarationOriginKind.UNBOX_METHOD_OF_INLINE_CLASS;
if (isOpenSuspendInClass) {
@@ -124,7 +124,8 @@ public class PropertyCodegen {
@Nullable KtPropertyAccessor getter,
@Nullable KtPropertyAccessor setter
) {
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DEFAULT_IMPLS
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION ||
kind == OwnerKind.DEFAULT_IMPLS || kind == OwnerKind.ERASED_INLINE_CLASS
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
genBackingFieldAndAnnotations(declaration, descriptor, false);