Take ReceiverParameterDescriptor in FunctionDescriptorImpl.initialize

Instead of just KotlinType. This will allow to pass annotations on the
receiver at call sites
This commit is contained in:
Alexander Udalov
2018-08-08 16:35:21 +02:00
parent 6fb39785ff
commit 34c033bcaf
39 changed files with 200 additions and 107 deletions
@@ -154,7 +154,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
}
private fun DeserializedSimpleFunctionDescriptor.initializeWithCoroutinesExperimentalityStatus(
receiverParameterType: KotlinType?,
extensionReceiverParameter: ReceiverParameterDescriptor?,
dispatchReceiverParameter: ReceiverParameterDescriptor?,
typeParameters: List<TypeParameterDescriptor>,
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
@@ -165,7 +165,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
isSuspend: Boolean
) {
initialize(
receiverParameterType,
extensionReceiverParameter,
dispatchReceiverParameter,
typeParameters,
unsubstitutedValueParameters,
@@ -174,7 +174,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
visibility,
userDataMap,
computeExperimentalityModeForFunctions(
receiverParameterType,
extensionReceiverParameter,
unsubstitutedValueParameters,
typeParameters,
unsubstitutedReturnType,
@@ -184,7 +184,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
}
private fun DeserializedCallableMemberDescriptor.computeExperimentalityModeForFunctions(
extensionReceiverType: KotlinType?,
extensionReceiverParameter: ReceiverParameterDescriptor?,
parameters: Collection<ValueParameterDescriptor>,
typeParameters: Collection<TypeParameterDescriptor>,
returnType: KotlinType?,
@@ -193,7 +193,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
if (!versionAndReleaseCoroutinesMismatch()) return CoroutinesCompatibilityMode.COMPATIBLE
if (fqNameOrNull() == KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME) return CoroutinesCompatibilityMode.COMPATIBLE
val types = parameters.map { it.type } + listOfNotNull(extensionReceiverType)
val types = parameters.map { it.type } + listOfNotNull(extensionReceiverParameter?.type)
if (returnType?.containsSuspendFunctionType() == true) return CoroutinesCompatibilityMode.INCOMPATIBLE
if (typeParameters.any { typeParameter -> typeParameter.upperBounds.any { it.containsSuspendFunctionType() } }) {
@@ -252,7 +252,9 @@ class MemberDeserializer(private val c: DeserializationContext) {
val local = c.childContext(function, proto.typeParameterList)
function.initializeWithCoroutinesExperimentalityStatus(
proto.receiverType(c.typeTable)?.let { local.typeDeserializer.type(it, receiverAnnotations) },
proto.receiverType(c.typeTable)?.let { local.typeDeserializer.type(it, receiverAnnotations) }?.let { receiverType ->
DescriptorFactory.createExtensionReceiverParameterForCallable(function, receiverType, Annotations.EMPTY)
},
getDispatchReceiverParameter(),
local.typeDeserializer.ownTypeParameters,
local.memberDeserializer.valueParameters(proto.valueParameterList, proto, AnnotatedCallableKind.FUNCTION),
@@ -76,7 +76,7 @@ class DeserializedSimpleFunctionDescriptor(
private set
fun initialize(
receiverParameterType: KotlinType?,
extensionReceiverParameter: ReceiverParameterDescriptor?,
dispatchReceiverParameter: ReceiverParameterDescriptor?,
typeParameters: List<TypeParameterDescriptor>,
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
@@ -87,7 +87,7 @@ class DeserializedSimpleFunctionDescriptor(
isExperimentalCoroutineInReleaseEnvironment: DeserializedMemberDescriptor.CoroutinesCompatibilityMode
): SimpleFunctionDescriptorImpl {
return super.initialize(
receiverParameterType,
extensionReceiverParameter,
dispatchReceiverParameter,
typeParameters,
unsubstitutedValueParameters,