Skip to content

Commit

Permalink
Fix local variables table for inline classes
Browse files Browse the repository at this point in the history
  • Loading branch information
zarechenskiy committed Feb 8, 2018
1 parent 35c454f commit b08a32a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Expand Up @@ -529,16 +529,18 @@ private static Type getThisTypeForFunction(
@NotNull KotlinTypeMapper typeMapper
) {
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
// all functions inside erased version of inline class are static, so they don't have `this` as is,
// but functions inside wrapper class should use type of wrapper class, not the underlying type
if (functionDescriptor instanceof ConstructorDescriptor) {
return typeMapper.mapType(functionDescriptor);
return typeMapper.mapTypeAsDeclaration(functionDescriptor);
}
else if (dispatchReceiver != null) {
return typeMapper.mapType(dispatchReceiver.getType());
return typeMapper.mapTypeAsDeclaration(dispatchReceiver.getType());
}
else if (isFunctionLiteral(functionDescriptor) ||
isLocalFunction(functionDescriptor) ||
isFunctionExpression(functionDescriptor)) {
return typeMapper.mapType(context.getThisDescriptor());
return typeMapper.mapClass(context.getThisDescriptor());
}
else {
return null;
Expand Down
Expand Up @@ -396,12 +396,23 @@ public Type mapType(@NotNull KotlinType jetType) {
return mapType(jetType, null, TypeMappingMode.DEFAULT);
}

@NotNull
public Type mapTypeAsDeclaration(@NotNull KotlinType kotlinType) {
return mapType(kotlinType, null, TypeMappingMode.CLASS_DECLARATION);
}

@NotNull
public Type mapType(@NotNull CallableDescriptor descriptor) {
//noinspection ConstantConditions
return mapType(descriptor.getReturnType());
}

@NotNull
public Type mapTypeAsDeclaration(@NotNull CallableDescriptor descriptor) {
//noinspection ConstantConditions
return mapTypeAsDeclaration(descriptor.getReturnType());
}

public Type mapErasedInlineClass(@NotNull ClassDescriptor descriptor) {
return Type.getObjectType(mapClass(descriptor).getInternalName() + JvmAbi.ERASED_INLINE_CLASS_SUFFIX);
}
Expand Down

0 comments on commit b08a32a

Please sign in to comment.