KT-52791 Make it possible to pass multiple context receivers to a class

This commit is contained in:
Pavel Mikhailovskii
2022-12-28 11:21:03 +00:00
committed by Space Team
parent 62217b39ec
commit 906c161068
38 changed files with 180 additions and 516 deletions
@@ -206,12 +206,13 @@ class TypeAliasConstructorDescriptorImpl private constructor(
val classDescriptor = typeAliasDescriptor.classDescriptor
val contextReceiverParameters = classDescriptor?.let {
constructor.contextReceiverParameters.map {
constructor.contextReceiverParameters.mapIndexed { index, contextReceiver ->
DescriptorFactory.createContextReceiverParameterForClass(
classDescriptor,
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT),
(it.value as ImplicitContextReceiver).customLabelName,
Annotations.EMPTY
substitutorForUnderlyingClass.safeSubstitute(contextReceiver.type, Variance.INVARIANT),
(contextReceiver.value as ImplicitContextReceiver).customLabelName,
Annotations.EMPTY,
index
)
}
} ?: emptyList()
@@ -246,10 +246,12 @@ public class DescriptorFactory {
@NotNull ClassDescriptor owner,
@Nullable KotlinType receiverParameterType,
@Nullable Name customLabelName,
@NotNull Annotations annotations
@NotNull Annotations annotations,
int index
) {
return receiverParameterType == null
? null
: new ReceiverParameterDescriptorImpl(owner, new ContextClassReceiver(owner, receiverParameterType, customLabelName, null), annotations);
: new ReceiverParameterDescriptorImpl(owner, new ContextClassReceiver(owner, receiverParameterType, customLabelName, null),
annotations, NameUtils.contextReceiverName(index));
}
}