Fix local variables table for inline classes
This commit is contained in:
@@ -529,16 +529,18 @@ public class FunctionCodegen {
|
|||||||
@NotNull KotlinTypeMapper typeMapper
|
@NotNull KotlinTypeMapper typeMapper
|
||||||
) {
|
) {
|
||||||
ReceiverParameterDescriptor dispatchReceiver = functionDescriptor.getDispatchReceiverParameter();
|
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) {
|
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||||
return typeMapper.mapType(functionDescriptor);
|
return typeMapper.mapTypeAsDeclaration(functionDescriptor);
|
||||||
}
|
}
|
||||||
else if (dispatchReceiver != null) {
|
else if (dispatchReceiver != null) {
|
||||||
return typeMapper.mapType(dispatchReceiver.getType());
|
return typeMapper.mapTypeAsDeclaration(dispatchReceiver.getType());
|
||||||
}
|
}
|
||||||
else if (isFunctionLiteral(functionDescriptor) ||
|
else if (isFunctionLiteral(functionDescriptor) ||
|
||||||
isLocalFunction(functionDescriptor) ||
|
isLocalFunction(functionDescriptor) ||
|
||||||
isFunctionExpression(functionDescriptor)) {
|
isFunctionExpression(functionDescriptor)) {
|
||||||
return typeMapper.mapType(context.getThisDescriptor());
|
return typeMapper.mapClass(context.getThisDescriptor());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -396,12 +396,23 @@ public class KotlinTypeMapper {
|
|||||||
return mapType(jetType, null, TypeMappingMode.DEFAULT);
|
return mapType(jetType, null, TypeMappingMode.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type mapTypeAsDeclaration(@NotNull KotlinType kotlinType) {
|
||||||
|
return mapType(kotlinType, null, TypeMappingMode.CLASS_DECLARATION);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Type mapType(@NotNull CallableDescriptor descriptor) {
|
public Type mapType(@NotNull CallableDescriptor descriptor) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return mapType(descriptor.getReturnType());
|
return mapType(descriptor.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Type mapTypeAsDeclaration(@NotNull CallableDescriptor descriptor) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
return mapTypeAsDeclaration(descriptor.getReturnType());
|
||||||
|
}
|
||||||
|
|
||||||
public Type mapErasedInlineClass(@NotNull ClassDescriptor descriptor) {
|
public Type mapErasedInlineClass(@NotNull ClassDescriptor descriptor) {
|
||||||
return Type.getObjectType(mapClass(descriptor).getInternalName() + JvmAbi.ERASED_INLINE_CLASS_SUFFIX);
|
return Type.getObjectType(mapClass(descriptor).getInternalName() + JvmAbi.ERASED_INLINE_CLASS_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user