Standardize context receiver parameter names
Previously, FIR used `_context_receiver_n` while FE10 used `<this>` for all context receiver parameters. This commit changes the code in FE10 to follow the convention from FIR.
This commit is contained in:
committed by
Alexander Udalov
parent
5cf1a88c42
commit
21fef70367
+5
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
@@ -36,6 +37,10 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
||||
super(annotations, SpecialNames.THIS);
|
||||
}
|
||||
|
||||
public AbstractReceiverParameterDescriptor(@NotNull Annotations annotations, @NotNull Name name) {
|
||||
super(annotations, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||
|
||||
+3
-1
@@ -628,6 +628,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
List<ReceiverParameterDescriptor> substitutedContextReceiverParameters = new ArrayList<ReceiverParameterDescriptor>();
|
||||
if (!configuration.newContextReceiverParameters.isEmpty()) {
|
||||
int index = 0;
|
||||
for (ReceiverParameterDescriptor newContextReceiverParameter : configuration.newContextReceiverParameters) {
|
||||
KotlinType substitutedContextReceiverType =
|
||||
substitutor.substitute(newContextReceiverParameter.getType(), Variance.IN_VARIANCE);
|
||||
@@ -637,7 +638,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
ReceiverParameterDescriptor substitutedContextReceiverParameter =
|
||||
DescriptorFactory.createContextReceiverParameterForCallable(substitutedDescriptor, substitutedContextReceiverType,
|
||||
((ImplicitContextReceiver)newContextReceiverParameter.getValue()).getCustomLabelName(),
|
||||
newContextReceiverParameter.getAnnotations());
|
||||
newContextReceiverParameter.getAnnotations(),
|
||||
index++);
|
||||
substitutedContextReceiverParameters.add(substitutedContextReceiverParameter);
|
||||
|
||||
wereChanges[0] |= substitutedContextReceiverType != newContextReceiverParameter.getType();
|
||||
|
||||
+12
-1
@@ -20,6 +20,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
@@ -33,7 +35,16 @@ public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDe
|
||||
@NotNull ReceiverValue value,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
super(annotations);
|
||||
this(containingDeclaration, value, annotations, SpecialNames.THIS);
|
||||
}
|
||||
|
||||
public ReceiverParameterDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ReceiverValue value,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name
|
||||
) {
|
||||
super(annotations, name);
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.*;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.NameUtils;
|
||||
import org.jetbrains.kotlin.name.StandardClassIds;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ContextClassReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ContextReceiver;
|
||||
@@ -231,11 +232,13 @@ public class DescriptorFactory {
|
||||
@NotNull CallableDescriptor owner,
|
||||
@Nullable KotlinType receiverParameterType,
|
||||
@Nullable Name customLabelName,
|
||||
@NotNull Annotations annotations
|
||||
@NotNull Annotations annotations,
|
||||
int index
|
||||
) {
|
||||
return receiverParameterType == null
|
||||
? null
|
||||
: new ReceiverParameterDescriptorImpl(owner, new ContextReceiver(owner, receiverParameterType, customLabelName, null), annotations);
|
||||
: new ReceiverParameterDescriptorImpl(owner, new ContextReceiver(owner, receiverParameterType, customLabelName, null), annotations,
|
||||
NameUtils.contextReceiverName(index));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user