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
@@ -18,13 +18,11 @@ package org.jetbrains.kotlin.load.java.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.SourceElement;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorFactory;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.List;
@@ -125,9 +123,13 @@ public class JavaClassConstructorDescriptor extends ClassConstructorDescriptorIm
) {
JavaClassConstructorDescriptor enhanced = createSubstitutedCopy(
getContainingDeclaration(), /* original = */ null, getKind(), null, getAnnotations(), getSource());
ReceiverParameterDescriptor enhancedReceiver =
enhancedReceiverType == null ? null : DescriptorFactory.createExtensionReceiverParameterForCallable(
enhanced, enhancedReceiverType, Annotations.Companion.getEMPTY()
);
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
enhanced.initialize(
enhancedReceiverType,
enhancedReceiver,
getDispatchReceiverParameter(),
getTypeParameters(),
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), enhanced),
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorFactory;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.util.OperatorChecks;
@@ -83,7 +84,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
@NotNull
@Override
public SimpleFunctionDescriptorImpl initialize(
@Nullable KotlinType receiverParameterType,
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
@@ -93,8 +94,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
@Nullable Map<? extends UserDataKey<?>, ?> userData
) {
SimpleFunctionDescriptorImpl descriptor = super.initialize(
receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
unsubstitutedReturnType, modality, visibility, userData);
extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
unsubstitutedReturnType, modality, visibility, userData
);
setOperator(OperatorChecks.INSTANCE.check(descriptor).isSuccess());
return descriptor;
}
@@ -147,11 +149,16 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
List<ValueParameterDescriptor> enhancedValueParameters =
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), this);
ReceiverParameterDescriptor enhancedReceiver =
enhancedReceiverType == null ? null : DescriptorFactory.createExtensionReceiverParameterForCallable(
this, enhancedReceiverType, Annotations.Companion.getEMPTY()
);
JavaMethodDescriptor enhancedMethod =
(JavaMethodDescriptor) newCopyBuilder()
.setValueParameters(enhancedValueParameters)
.setReturnType(enhancedReturnType)
.setExtensionReceiverType(enhancedReceiverType)
.setExtensionReceiverParameter(enhancedReceiver)
.setDropOriginalInContainingParts()
.setPreserveSourceElement()
.build();
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
@@ -35,6 +36,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaField
import org.jetbrains.kotlin.load.java.structure.JavaMethod
import org.jetbrains.kotlin.load.java.structure.JavaValueParameter
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.constants.StringValue
import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgument
@@ -130,14 +132,16 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
val effectiveSignature = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters.descriptors)
functionDescriptorImpl.initialize(
effectiveSignature.receiverType,
getDispatchReceiverParameter(),
effectiveSignature.typeParameters,
effectiveSignature.valueParameters,
effectiveSignature.returnType,
Modality.convertFromFlags(method.isAbstract, !method.isFinal),
method.visibility,
if (effectiveSignature.receiverType != null)
effectiveSignature.receiverType?.let {
DescriptorFactory.createExtensionReceiverParameterForCallable(functionDescriptorImpl, it, Annotations.EMPTY)
},
getDispatchReceiverParameter(),
effectiveSignature.typeParameters,
effectiveSignature.valueParameters,
effectiveSignature.returnType,
Modality.convertFromFlags(method.isAbstract, !method.isFinal),
method.visibility,
if (effectiveSignature.receiverType != null)
mapOf(JavaMethodDescriptor.ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER to valueParameters.descriptors.first())
else
emptyMap<FunctionDescriptor.UserDataKey<ValueParameterDescriptor>, ValueParameterDescriptor>()
@@ -114,7 +114,7 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
CopyBuilder<D> setReturnType(@NotNull KotlinType type);
@NotNull
CopyBuilder<D> setExtensionReceiverType(@Nullable KotlinType type);
CopyBuilder<D> setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter);
@NotNull
@Override
@@ -22,11 +22,13 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.TypeSubstitutor;
public interface ReceiverParameterDescriptor extends ParameterDescriptor {
@NotNull
ReceiverValue getValue();
@Nullable
@Override
ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor);
@NotNull
ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner);
}
@@ -33,8 +33,8 @@ import java.util.List;
public abstract class AbstractReceiverParameterDescriptor extends DeclarationDescriptorImpl implements ReceiverParameterDescriptor {
private static final Name RECEIVER_PARAMETER_NAME = Name.special("<this>");
public AbstractReceiverParameterDescriptor() {
super(Annotations.Companion.getEMPTY(), RECEIVER_PARAMETER_NAME);
public AbstractReceiverParameterDescriptor(@NotNull Annotations annotations) {
super(annotations, RECEIVER_PARAMETER_NAME);
}
@Nullable
@@ -58,7 +58,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
if (substitutedType == null) return null;
if (substitutedType == getType()) return this;
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType));
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType), getAnnotations());
}
@Override
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsKt;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorFactory;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.utils.SmartList;
@@ -66,7 +66,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull
public FunctionDescriptorImpl initialize(
@Nullable KotlinType receiverParameterType,
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
@@ -79,7 +79,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
this.unsubstitutedReturnType = unsubstitutedReturnType;
this.modality = modality;
this.visibility = visibility;
this.extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverParameterType);
this.extensionReceiverParameter = extensionReceiverParameter;
this.dispatchReceiverParameter = dispatchReceiverParameter;
for (int i = 0; i < typeParameters.size(); ++i) {
@@ -350,7 +350,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
protected @Nullable FunctionDescriptor original = null;
protected @NotNull Kind kind;
protected @NotNull List<ValueParameterDescriptor> newValueParameterDescriptors;
protected @Nullable KotlinType newExtensionReceiverParameterType;
protected @Nullable ReceiverParameterDescriptor newExtensionReceiverParameter;
protected @Nullable ReceiverParameterDescriptor dispatchReceiverParameter = FunctionDescriptorImpl.this.dispatchReceiverParameter;
protected @NotNull KotlinType newReturnType;
protected @Nullable Name name;
@@ -373,7 +373,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull Visibility newVisibility,
@NotNull Kind kind,
@NotNull List<ValueParameterDescriptor> newValueParameterDescriptors,
@Nullable KotlinType newExtensionReceiverParameterType,
@Nullable ReceiverParameterDescriptor newExtensionReceiverParameter,
@NotNull KotlinType newReturnType,
@Nullable Name name
) {
@@ -383,7 +383,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
this.newVisibility = newVisibility;
this.kind = kind;
this.newValueParameterDescriptors = newValueParameterDescriptors;
this.newExtensionReceiverParameterType = newExtensionReceiverParameterType;
this.newExtensionReceiverParameter = newExtensionReceiverParameter;
this.newReturnType = newReturnType;
this.name = name;
}
@@ -453,8 +453,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull
@Override
public CopyConfiguration setExtensionReceiverType(@Nullable KotlinType type) {
this.newExtensionReceiverParameterType = type;
public CopyConfiguration setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter) {
this.newExtensionReceiverParameter = extensionReceiverParameter;
return this;
}
@@ -567,7 +567,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
return new CopyConfiguration(
substitutor.getSubstitution(),
getContainingDeclaration(), getModality(), getVisibility(), getKind(), getValueParameters(),
getExtensionReceiverParameterType(), getReturnType(), null);
getExtensionReceiverParameter(), getReturnType(), null
);
}
@Nullable
@@ -594,14 +595,22 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
);
if (substitutor == null) return null;
KotlinType substitutedReceiverParameterType = null;
if (configuration.newExtensionReceiverParameterType != null) {
substitutedReceiverParameterType = substitutor.substitute(configuration.newExtensionReceiverParameterType, Variance.IN_VARIANCE);
if (substitutedReceiverParameterType == null) {
ReceiverParameterDescriptor substitutedReceiverParameter = null;
if (configuration.newExtensionReceiverParameter != null) {
KotlinType substitutedExtensionReceiverType =
substitutor.substitute(configuration.newExtensionReceiverParameter.getType(), Variance.IN_VARIANCE);
if (substitutedExtensionReceiverType == null) {
return null;
}
substitutedReceiverParameter = new ReceiverParameterDescriptorImpl(
substitutedDescriptor,
new ExtensionReceiver(
substitutedDescriptor, substitutedExtensionReceiverType, configuration.newExtensionReceiverParameter.getValue()
),
configuration.newExtensionReceiverParameter.getAnnotations()
);
wereChanges[0] |= substitutedReceiverParameterType != configuration.newExtensionReceiverParameterType;
wereChanges[0] |= substitutedExtensionReceiverType != configuration.newExtensionReceiverParameter.getType();
}
ReceiverParameterDescriptor substitutedExpectedThis = null;
@@ -644,7 +653,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
}
substitutedDescriptor.initialize(
substitutedReceiverParameterType,
substitutedReceiverParameter,
substitutedExpectedThis,
substitutedTypeParameters,
substitutedValueParameters,
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.descriptors.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
@@ -27,6 +29,7 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame
private final ImplicitClassReceiver receiverValue;
public LazyClassReceiverParameterDescriptor(@NotNull ClassDescriptor descriptor) {
super(Annotations.Companion.getEMPTY());
this.descriptor = descriptor;
this.receiverValue = new ImplicitClassReceiver(descriptor, null);
}
@@ -43,6 +46,12 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame
return descriptor;
}
@NotNull
@Override
public ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return "class " + descriptor.getName() + "::this";
@@ -112,7 +112,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@Nullable KotlinType receiverType
) {
ReceiverParameterDescriptor extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType);
ReceiverParameterDescriptor extensionReceiverParameter =
DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType, Annotations.Companion.getEMPTY());
setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter);
}
@@ -19,13 +19,19 @@ package org.jetbrains.kotlin.descriptors.impl;
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.resolve.scopes.receivers.ReceiverValue;
public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor {
private final DeclarationDescriptor containingDeclaration;
private final ReceiverValue value;
public ReceiverParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, @NotNull ReceiverValue value) {
public ReceiverParameterDescriptorImpl(
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull ReceiverValue value,
@NotNull Annotations annotations
) {
super(annotations);
this.containingDeclaration = containingDeclaration;
this.value = value;
}
@@ -41,4 +47,10 @@ public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDe
public DeclarationDescriptor getContainingDeclaration() {
return containingDeclaration;
}
@NotNull
@Override
public ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
return new ReceiverParameterDescriptorImpl(newOwner, value, getAnnotations());
}
}
@@ -53,7 +53,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
@NotNull
@Override
public SimpleFunctionDescriptorImpl initialize(
@Nullable KotlinType receiverParameterType,
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
@@ -61,13 +61,13 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
@Nullable Modality modality,
@NotNull Visibility visibility
) {
return initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
return initialize(extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
unsubstitutedReturnType, modality, visibility, null);
}
@NotNull
public SimpleFunctionDescriptorImpl initialize(
@Nullable KotlinType receiverParameterType,
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
@@ -76,7 +76,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
@NotNull Visibility visibility,
@Nullable Map<? extends UserDataKey<?>, ?> userData
) {
super.initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
super.initialize(extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
unsubstitutedReturnType, modality, visibility);
if (userData != null && !userData.isEmpty()) {
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue
import org.jetbrains.kotlin.types.*
@@ -192,12 +193,16 @@ class TypeAliasConstructorDescriptorImpl private constructor(
val returnType = substitutedConstructor.returnType.unwrap().lowerIfFlexible().withAbbreviation(typeAliasDescriptor.defaultType)
val receiverParameterType = constructor.dispatchReceiverParameter?.let {
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT)
val receiverParameter = constructor.dispatchReceiverParameter?.let {
DescriptorFactory.createExtensionReceiverParameterForCallable(
typeAliasConstructor,
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT),
Annotations.EMPTY
)
}
typeAliasConstructor.initialize(
receiverParameterType,
receiverParameter,
null,
typeAliasDescriptor.declaredTypeParameters,
valueParameters,
@@ -168,10 +168,11 @@ public class DescriptorFactory {
@Nullable
public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable(
@NotNull CallableDescriptor owner,
@Nullable KotlinType receiverParameterType
@Nullable KotlinType receiverParameterType,
@NotNull Annotations annotations
) {
return receiverParameterType == null
? null
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType, null));
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType, null), annotations);
}
}
@@ -123,7 +123,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
@NotNull
@Override
public CopyBuilder<SimpleFunctionDescriptor> setExtensionReceiverType(@Nullable KotlinType type) {
public CopyBuilder<SimpleFunctionDescriptor> setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter) {
return this;
}
@@ -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,