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,7 +18,6 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
@@ -56,7 +55,7 @@ class AccessorForConstructorDescriptor(
init {
initialize(
DescriptorUtils.getReceiverParameterType(extensionReceiverParameter),
calleeDescriptor.extensionReceiverParameter?.copy(this),
calleeDescriptor.dispatchReceiverParameter,
copyTypeParameters(calleeDescriptor),
copyValueParameters(calleeDescriptor),
@@ -16,14 +16,12 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.coroutines.*
import org.jetbrains.kotlin.codegen.coroutines.INITIAL_DESCRIPTOR_FOR_SUSPEND_FUNCTION
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import java.util.LinkedHashMap
import java.util.*
class AccessorForFunctionDescriptor(
override val calleeDescriptor: FunctionDescriptor,
@@ -36,7 +34,7 @@ class AccessorForFunctionDescriptor(
init {
initialize(
DescriptorUtils.getReceiverParameterType(calleeDescriptor.extensionReceiverParameter),
calleeDescriptor.extensionReceiverParameter?.copy(this),
if (calleeDescriptor is ConstructorDescriptor || calleeDescriptor.isJvmStaticInObjectOrClassOrInterface())
null
else
@@ -185,7 +185,7 @@ class CoroutineCodegenForLambda private constructor(
funDescriptor.source
).also {
it.initialize(
funDescriptor.extensionReceiverParameter?.type,
funDescriptor.extensionReceiverParameter?.copy(it),
funDescriptor.dispatchReceiverParameter,
funDescriptor.typeParameters,
funDescriptor.valueParameters,
@@ -22,7 +22,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.*;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
@@ -90,7 +91,7 @@ public class SignaturesPropagationData {
SourceElement.NO_SOURCE
);
autoMethodDescriptor.initialize(
/* receiverParameterType = */ null,
null,
containingClass.getThisAsReceiverParameter(),
autoTypeParameters,
autoValueParameters,
@@ -930,8 +930,15 @@ public class DescriptorResolver {
}
}
ReceiverParameterDescriptor receiverDescriptor =
DescriptorFactory.createExtensionReceiverParameterForCallable(propertyDescriptor, receiverType);
ReceiverParameterDescriptor receiverDescriptor;
if (receiverType != null) {
receiverDescriptor = DescriptorFactory.createExtensionReceiverParameterForCallable(
propertyDescriptor, receiverType, Annotations.Companion.getEMPTY()
);
}
else {
receiverDescriptor = null;
}
LexicalScope scopeForInitializer = ScopeUtils.makeScopeForPropertyInitializer(scopeForInitializerResolutionWithTypeParameters, propertyDescriptor);
KotlinType propertyType = propertyInfo.getVariableType();
@@ -210,7 +210,9 @@ class FunctionDescriptorResolver(
}
functionDescriptor.initialize(
receiverType,
receiverType?.let {
DescriptorFactory.createExtensionReceiverParameterForCallable(functionDescriptor, it, Annotations.EMPTY)
},
getDispatchReceiverParameterIfNeeded(container),
typeParameterDescriptors,
valueParameterDescriptors,
@@ -138,7 +138,7 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
}
private fun createDynamicDispatchReceiverParameter(owner: CallableDescriptor): ReceiverParameterDescriptorImpl {
return ReceiverParameterDescriptorImpl(owner, TransientReceiver(dynamicType))
return ReceiverParameterDescriptorImpl(owner, TransientReceiver(dynamicType), Annotations.EMPTY)
}
private fun createTypeParameters(owner: DeclarationDescriptor, call: Call): List<TypeParameterDescriptor> =
@@ -159,19 +159,19 @@ class ResolvedAtomCompleter(
trace.recordType(ktArgumentExpression, substitutedFunctionalType)
// Mainly this is needed for builder-like inference, when we have type `SomeType<K, V>.() -> Unit` and now we want to update those K, V
val extensionReceiverParameter = functionDescriptor.extensionReceiverParameter
if (extensionReceiverParameter != null) {
require(extensionReceiverParameter is ReceiverParameterDescriptorImpl) {
"Extension receiver for anonymous function ($extensionReceiverParameter) should be ReceiverParameterDescriptorImpl"
val receiver = functionDescriptor.extensionReceiverParameter
if (receiver != null) {
require(receiver is ReceiverParameterDescriptorImpl) {
"Extension receiver for anonymous function ($receiver) should be ReceiverParameterDescriptorImpl"
}
val valueType = extensionReceiverParameter.value.type.unwrap()
val valueType = receiver.value.type.unwrap()
val newValueType = resultSubstitutor.substituteKeepAnnotations(valueType)
val newReceiverValue = extensionReceiverParameter.value.replaceType(newValueType)
val newReceiverValue = receiver.value.replaceType(newValueType)
functionDescriptor.setExtensionReceiverParameter(
ReceiverParameterDescriptorImpl(extensionReceiverParameter.containingDeclaration, newReceiverValue)
ReceiverParameterDescriptorImpl(receiver.containingDeclaration, newReceiverValue, receiver.annotations)
)
}
}
@@ -396,7 +396,7 @@ private fun IrFunction.generateDefaultsFunction(context: CommonBackendContext):
} + syntheticParameters
descriptor.initialize(
/* receiverParameterType = */ extensionReceiverParameter?.type,
/* receiverParameterType = */ extensionReceiverParameter,
/* dispatchReceiverParameter = */ dispatchReceiverParameter,
/* typeParameters = */ typeParameters.map {
TypeParameterDescriptorImpl.createForFurtherModification(
@@ -520,7 +520,7 @@ class LocalDeclarationsLowering(
val newValueParameters = createTransformedValueParameters(localFunctionContext, capturedValues)
newDescriptor.initialize(
oldDescriptor.extensionReceiverParameter?.type,
oldDescriptor.extensionReceiverParameter?.copy(newDescriptor),
newDispatchReceiverParameter,
newTypeParameters,
newValueParameters.map { it.descriptor as ValueParameterDescriptor },
@@ -123,7 +123,7 @@ class BridgesConstruction(val context: JsIrBackendContext) : ClassLoweringPass {
)
bridgeDescriptorForIrFunction.initialize(
bridge.descriptor.extensionReceiverParameter?.returnType, containingClass.thisAsReceiverParameter,
bridge.descriptor.extensionReceiverParameter?.copy(bridge.descriptor), containingClass.thisAsReceiverParameter,
bridge.descriptor.typeParameters,
bridge.descriptor.valueParameters.map { it.copy(bridgeDescriptorForIrFunction, it.name, it.index) },
bridge.descriptor.returnType, bridge.descriptor.modality, function.visibility
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeSubstitutor
@@ -315,11 +316,11 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
val newDispatchReceiverParameter = oldDispatchReceiverParameter?.let { descriptorSubstituteMap.getOrDefault(it, it) as ReceiverParameterDescriptor }
val newTypeParameters = oldDescriptor.typeParameters // TODO substitute types
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
val newReceiverParameterType = substituteTypeAndTryGetCopied(oldDescriptor.extensionReceiverParameter?.type)
val newReceiverParameter = copyReceiverParameter(oldDescriptor.extensionReceiverParameter, this)
val newReturnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
initialize(
/* receiverParameterType = */ newReceiverParameterType,
/* extensionReceiverParameter = */ newReceiverParameter,
/* dispatchReceiverParameter = */ newDispatchReceiverParameter,
/* typeParameters = */ newTypeParameters,
/* unsubstitutedValueParameters = */ newValueParameters,
@@ -338,11 +339,11 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
(descriptorSubstituteMap[oldDescriptor] as ClassConstructorDescriptorImpl).apply {
val newTypeParameters = oldDescriptor.typeParameters
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
val receiverParameterType = substituteTypeAndTryGetCopied(oldDescriptor.dispatchReceiverParameter?.type)
val newReceiverParameter = copyReceiverParameter(oldDescriptor.dispatchReceiverParameter, this)
val returnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
initialize(
/* receiverParameterType = */ receiverParameterType,
/* extensionReceiverParameter = */ newReceiverParameter,
/* dispatchReceiverParameter = */ null, // For constructor there is no explicit dispatch receiver.
/* typeParameters = */ newTypeParameters,
/* unsubstitutedValueParameters = */ newValueParameters,
@@ -431,6 +432,18 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
newDescriptor
}
private fun copyReceiverParameter(
oldReceiverParameter: ReceiverParameterDescriptor?, containingDeclaration: CallableDescriptor
): ReceiverParameterDescriptor? {
if (oldReceiverParameter == null) return null
val substituteTypeAndTryGetCopied = substituteTypeAndTryGetCopied(oldReceiverParameter.type) ?: return null
return ReceiverParameterDescriptorImpl(
containingDeclaration,
ExtensionReceiver(containingDeclaration, substituteTypeAndTryGetCopied, oldReceiverParameter.value),
oldReceiverParameter.annotations
)
}
private fun substituteTypeAndTryGetCopied(type: KotlinType?): KotlinType? {
val substitutedType = substituteType(type) ?: return null
val oldClassDescriptor = TypeUtils.getClassDescriptor(substitutedType) ?: return substitutedType
@@ -84,7 +84,7 @@ object JsSymbolBuilder {
fun IrSimpleFunctionSymbol.initialize(
receiverParameterType: IrType? = null,
extensionReceiverParameter: ReceiverParameterDescriptor? = null,
dispatchParameterDescriptor: ReceiverParameterDescriptor? = null,
typeParameters: List<TypeParameterDescriptor> = emptyList(),
valueParameters: List<ValueParameterDescriptor> = emptyList(),
@@ -93,7 +93,7 @@ fun IrSimpleFunctionSymbol.initialize(
visibility: Visibility = Visibilities.LOCAL
) = this.apply {
(descriptor as FunctionDescriptorImpl).initialize(
receiverParameterType?.toKotlinType(),
extensionReceiverParameter,
dispatchParameterDescriptor,
typeParameters,
valueParameters,
@@ -101,4 +101,4 @@ fun IrSimpleFunctionSymbol.initialize(
modality,
visibility
)
}
}
@@ -95,7 +95,7 @@ class JvmDescriptorsFactory(
// Call the long version of `initialize()`, because otherwise default implementation inserts
// an unwanted `dispatchReceiverParameter`
newDescriptor.initialize(
oldDescriptor.extensionReceiverParameter?.type,
oldDescriptor.extensionReceiverParameter?.copy(newDescriptor),
null,
oldDescriptor.typeParameters,
newValueParameters,
@@ -197,7 +197,8 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
)
bridgeDescriptorForIrFunction.initialize(
bridge.descriptor.extensionReceiverParameter?.returnType, containingClass.thisAsReceiverParameter, emptyList(),
bridge.descriptor.extensionReceiverParameter?.copy(bridgeDescriptorForIrFunction),
containingClass.thisAsReceiverParameter, emptyList(),
bridge.descriptor.valueParameters.map { it.copy(bridgeDescriptorForIrFunction, it.name, it.index) },
bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility
)
@@ -329,7 +330,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
)
delegationDescriptor.initialize(
descriptor.extensionReceiverParameter?.returnType, containingClass.thisAsReceiverParameter, emptyList(),
descriptor.extensionReceiverParameter?.copy(delegationDescriptor), containingClass.thisAsReceiverParameter, emptyList(),
descriptor.valueParameters.map { it.copy(delegationDescriptor, it.name, it.index) },
descriptor.returnType, Modality.OPEN, descriptor.visibility
)
@@ -8,11 +8,17 @@ package org.jetbrains.kotlin.backend.jvm.lower
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.addMember
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
@@ -148,7 +154,7 @@ class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : ClassLowe
// Call the long version of `initialize()`, because otherwise default implementation inserts
// an unwanted `dispatchReceiverParameter`.
result.initialize(
extensionReceiverParameter?.type,
extensionReceiverParameter?.copy(result),
dispatchReceiverParameter,
typeParameters,
generateNewValueParameters(this, numDefaultParametersToExpect),
@@ -18,8 +18,6 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
@@ -30,7 +28,11 @@ import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.*
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
import org.jetbrains.org.objectweb.asm.Opcodes
/*
@@ -227,7 +229,7 @@ private fun makeJvmStaticFunctionSymbol(
)
proxyDescriptorForIrFunction.initialize(
oldFunctionSymbol.descriptor.extensionReceiverParameter?.type,
oldFunctionSymbol.descriptor.extensionReceiverParameter?.copy(proxyDescriptorForIrFunction),
null,
oldFunctionSymbol.descriptor.typeParameters,
oldFunctionSymbol.descriptor.valueParameters.map { it.copy(proxyDescriptorForIrFunction, it.name, it.index) },
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.usesDefaultArguments
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.KotlinType
interface StubContext {
@@ -315,7 +314,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : FileLoweringPa
private fun AccessorForConstructorDescriptor.constructorDescriptorWithMarker(marker: KotlinType) =
ClassConstructorDescriptorImpl.createSynthesized(containingDeclaration, annotations, false, source).also {
it.initialize(
DescriptorUtils.getReceiverParameterType(extensionReceiverParameter),
extensionReceiverParameter?.copy(this),
dispatchReceiverParameter,
emptyList()/*TODO*/,
calleeDescriptor.valueParameters.map {
@@ -22,7 +22,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.descriptorUtil.setSingleOverridden
import org.jetbrains.kotlin.types.TypeSubstitutor
@@ -66,7 +68,11 @@ fun createSynthesizedInvokes(functions: Collection<FunctionDescriptor>): Collect
private fun createSynthesizedFunctionWithFirstParameterAsReceiver(descriptor: FunctionDescriptor) =
descriptor.original.newCopyBuilder().apply {
setExtensionReceiverType(descriptor.original.valueParameters.first().type)
setExtensionReceiverParameter(
DescriptorFactory.createExtensionReceiverParameterForCallable(
descriptor.original, descriptor.original.valueParameters.first().type, Annotations.EMPTY
)
)
setValueParameters(
descriptor.original.valueParameters
.drop(1)
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl;
import org.jetbrains.kotlin.psi.KtExpression;
@@ -544,7 +545,8 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
KotlinType thisType = makeType(contextType);
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(
scopeWithImports.getOwnerDescriptor(),
new TransientReceiver(thisType)
new TransientReceiver(thisType),
Annotations.Companion.getEMPTY()
);
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false,
@@ -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,
@@ -31,8 +31,8 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.load.java.NOT_NULL_ANNOTATIONS
@@ -219,7 +219,7 @@ class ChangeMemberFunctionSignatureFix private constructor(
return descriptor.apply {
initialize(
function.extensionReceiverParameter?.type, function.dispatchReceiverParameter,
function.extensionReceiverParameter?.copy(this), function.dispatchReceiverParameter,
function.typeParameters, parameters, function.returnType, function.modality, function.visibility
)
isOperator = function.isOperator
@@ -59,7 +59,7 @@ internal class ChangeMethodParameters(
SourceElement.NO_SOURCE
).apply {
initialize(
functionDescriptor.extensionReceiverParameter?.type,
functionDescriptor.extensionReceiverParameter?.copy(this),
functionDescriptor.dispatchReceiverParameter,
functionDescriptor.typeParameters,
request.withIndex().map { (index, parameter) ->
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
@@ -46,8 +47,10 @@ internal fun genClearCacheFunction(packageFragmentDescriptor: PackageFragmentDes
SourceElement.NO_SOURCE) {}
val unitType = packageFragmentDescriptor.builtIns.unitType
function.initialize(receiverType, null, emptyList(), emptyList(), unitType, Modality.FINAL, Visibilities.PUBLIC)
return function
return function.initialize(
DescriptorFactory.createExtensionReceiverParameterForCallable(function, receiverType, Annotations.EMPTY),
null, emptyList(), emptyList(), unitType, Modality.FINAL, Visibilities.PUBLIC
)
}
internal fun genPropertyForWidget(