Skip call to the underlying value of inline class
This commit is contained in:
@@ -1672,14 +1672,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||
|
||||
// `this` is represented as first parameter of function in erased inline class
|
||||
boolean isThisOfErasedInlineClass =
|
||||
contextKind() == OwnerKind.ERASED_INLINE_CLASS &&
|
||||
boolean isUnderlyingPropertyOfInlineClass =
|
||||
InlineClassesUtilsKt.isInlineClass(propertyDescriptor.getContainingDeclaration()) &&
|
||||
JvmCodegenUtil.hasBackingField(propertyDescriptor, contextKind(), bindingContext);
|
||||
if (isThisOfErasedInlineClass) {
|
||||
Type underlyingRepresentationType = typeMapper.mapType(propertyDescriptor.getType());
|
||||
return StackValue.local(0, underlyingRepresentationType);
|
||||
|
||||
if (isUnderlyingPropertyOfInlineClass) {
|
||||
KotlinType propertyType = propertyDescriptor.getType();
|
||||
return StackValue.underlyingValueOfInlineClass(typeMapper.mapType(propertyType), propertyType, receiver);
|
||||
}
|
||||
|
||||
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Companion.getInstances(state.getProject());
|
||||
|
||||
@@ -291,6 +291,14 @@ public abstract class StackValue {
|
||||
return new CollectionElement(collectionElementReceiver, type, kotlinType, getter, setter, codegen);
|
||||
}
|
||||
|
||||
public static UnderlyingValueOfInlineClass underlyingValueOfInlineClass(
|
||||
@NotNull Type type,
|
||||
@Nullable KotlinType kotlinType,
|
||||
@NotNull StackValue receiver
|
||||
) {
|
||||
return new UnderlyingValueOfInlineClass(type, kotlinType, receiver);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Field field(@NotNull Type type, @NotNull Type owner, @NotNull String name, boolean isStatic, @NotNull StackValue receiver) {
|
||||
return field(type, null, owner, name, isStatic, receiver, null);
|
||||
@@ -1004,6 +1012,24 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
|
||||
public static class UnderlyingValueOfInlineClass extends StackValueWithSimpleReceiver {
|
||||
|
||||
public UnderlyingValueOfInlineClass(
|
||||
@NotNull Type type,
|
||||
@Nullable KotlinType kotlinType,
|
||||
@NotNull StackValue receiver
|
||||
) {
|
||||
super(type, kotlinType, false, false, receiver, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putSelector(
|
||||
@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v
|
||||
) {
|
||||
coerceTo(type, kotlinType, v);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CollectionElementReceiver extends StackValue {
|
||||
private final Callable callable;
|
||||
private final boolean isGetter;
|
||||
|
||||
Reference in New Issue
Block a user