[FE, PSI2IR] Pass context receivers when calling typealias constructor
This commit is contained in:
committed by
TeamCityServer
parent
fb99df235e
commit
bd4e51f304
+13
-2
@@ -83,7 +83,7 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
typeAliasConstructor.initialize(
|
||||
null,
|
||||
underlyingConstructorDescriptor.dispatchReceiverParameter?.substitute(substitutorForUnderlyingClass),
|
||||
emptyList(),
|
||||
underlyingConstructorDescriptor.contextReceiverParameters.map { it.substitute(substitutorForUnderlyingClass) },
|
||||
typeAliasDescriptor.declaredTypeParameters,
|
||||
valueParameters,
|
||||
returnType,
|
||||
@@ -203,10 +203,21 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
val classDescriptor = typeAliasDescriptor.classDescriptor
|
||||
val contextReceiverParameters = classDescriptor?.let {
|
||||
constructor.contextReceiverParameters.map {
|
||||
DescriptorFactory.createContextReceiverParameterForClass(
|
||||
classDescriptor,
|
||||
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT),
|
||||
Annotations.EMPTY
|
||||
)
|
||||
}
|
||||
} ?: emptyList()
|
||||
|
||||
typeAliasConstructor.initialize(
|
||||
receiverParameter,
|
||||
null,
|
||||
emptyList(),
|
||||
contextReceiverParameters,
|
||||
typeAliasDescriptor.declaredTypeParameters,
|
||||
valueParameters,
|
||||
returnType,
|
||||
|
||||
@@ -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.resolve.scopes.receivers.ContextClassReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ContextReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
@@ -205,4 +206,15 @@ public class DescriptorFactory {
|
||||
? null
|
||||
: new ReceiverParameterDescriptorImpl(owner, new ContextReceiver(owner, receiverParameterType, null), annotations);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ReceiverParameterDescriptor createContextReceiverParameterForClass(
|
||||
@NotNull ClassDescriptor owner,
|
||||
@Nullable KotlinType receiverParameterType,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return receiverParameterType == null
|
||||
? null
|
||||
: new ReceiverParameterDescriptorImpl(owner, new ContextClassReceiver(owner, receiverParameterType, null), annotations);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user