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:
+1
-2
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.codegen
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ class AccessorForConstructorDescriptor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
initialize(
|
initialize(
|
||||||
DescriptorUtils.getReceiverParameterType(extensionReceiverParameter),
|
calleeDescriptor.extensionReceiverParameter?.copy(this),
|
||||||
calleeDescriptor.dispatchReceiverParameter,
|
calleeDescriptor.dispatchReceiverParameter,
|
||||||
copyTypeParameters(calleeDescriptor),
|
copyTypeParameters(calleeDescriptor),
|
||||||
copyValueParameters(calleeDescriptor),
|
copyValueParameters(calleeDescriptor),
|
||||||
|
|||||||
@@ -16,14 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.codegen
|
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.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import java.util.*
|
||||||
|
|
||||||
import java.util.LinkedHashMap
|
|
||||||
|
|
||||||
class AccessorForFunctionDescriptor(
|
class AccessorForFunctionDescriptor(
|
||||||
override val calleeDescriptor: FunctionDescriptor,
|
override val calleeDescriptor: FunctionDescriptor,
|
||||||
@@ -36,7 +34,7 @@ class AccessorForFunctionDescriptor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
initialize(
|
initialize(
|
||||||
DescriptorUtils.getReceiverParameterType(calleeDescriptor.extensionReceiverParameter),
|
calleeDescriptor.extensionReceiverParameter?.copy(this),
|
||||||
if (calleeDescriptor is ConstructorDescriptor || calleeDescriptor.isJvmStaticInObjectOrClassOrInterface())
|
if (calleeDescriptor is ConstructorDescriptor || calleeDescriptor.isJvmStaticInObjectOrClassOrInterface())
|
||||||
null
|
null
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class CoroutineCodegenForLambda private constructor(
|
|||||||
funDescriptor.source
|
funDescriptor.source
|
||||||
).also {
|
).also {
|
||||||
it.initialize(
|
it.initialize(
|
||||||
funDescriptor.extensionReceiverParameter?.type,
|
funDescriptor.extensionReceiverParameter?.copy(it),
|
||||||
funDescriptor.dispatchReceiverParameter,
|
funDescriptor.dispatchReceiverParameter,
|
||||||
funDescriptor.typeParameters,
|
funDescriptor.typeParameters,
|
||||||
funDescriptor.valueParameters,
|
funDescriptor.valueParameters,
|
||||||
|
|||||||
+3
-2
@@ -22,7 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
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.descriptors.impl.ValueParameterDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
|
||||||
@@ -90,7 +91,7 @@ public class SignaturesPropagationData {
|
|||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
);
|
);
|
||||||
autoMethodDescriptor.initialize(
|
autoMethodDescriptor.initialize(
|
||||||
/* receiverParameterType = */ null,
|
null,
|
||||||
containingClass.getThisAsReceiverParameter(),
|
containingClass.getThisAsReceiverParameter(),
|
||||||
autoTypeParameters,
|
autoTypeParameters,
|
||||||
autoValueParameters,
|
autoValueParameters,
|
||||||
|
|||||||
@@ -930,8 +930,15 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiverParameterDescriptor receiverDescriptor =
|
ReceiverParameterDescriptor receiverDescriptor;
|
||||||
DescriptorFactory.createExtensionReceiverParameterForCallable(propertyDescriptor, receiverType);
|
if (receiverType != null) {
|
||||||
|
receiverDescriptor = DescriptorFactory.createExtensionReceiverParameterForCallable(
|
||||||
|
propertyDescriptor, receiverType, Annotations.Companion.getEMPTY()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
receiverDescriptor = null;
|
||||||
|
}
|
||||||
|
|
||||||
LexicalScope scopeForInitializer = ScopeUtils.makeScopeForPropertyInitializer(scopeForInitializerResolutionWithTypeParameters, propertyDescriptor);
|
LexicalScope scopeForInitializer = ScopeUtils.makeScopeForPropertyInitializer(scopeForInitializerResolutionWithTypeParameters, propertyDescriptor);
|
||||||
KotlinType propertyType = propertyInfo.getVariableType();
|
KotlinType propertyType = propertyInfo.getVariableType();
|
||||||
|
|||||||
@@ -210,7 +210,9 @@ class FunctionDescriptorResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
functionDescriptor.initialize(
|
functionDescriptor.initialize(
|
||||||
receiverType,
|
receiverType?.let {
|
||||||
|
DescriptorFactory.createExtensionReceiverParameterForCallable(functionDescriptor, it, Annotations.EMPTY)
|
||||||
|
},
|
||||||
getDispatchReceiverParameterIfNeeded(container),
|
getDispatchReceiverParameterIfNeeded(container),
|
||||||
typeParameterDescriptors,
|
typeParameterDescriptors,
|
||||||
valueParameterDescriptors,
|
valueParameterDescriptors,
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createDynamicDispatchReceiverParameter(owner: CallableDescriptor): ReceiverParameterDescriptorImpl {
|
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> =
|
private fun createTypeParameters(owner: DeclarationDescriptor, call: Call): List<TypeParameterDescriptor> =
|
||||||
|
|||||||
+7
-7
@@ -159,19 +159,19 @@ class ResolvedAtomCompleter(
|
|||||||
trace.recordType(ktArgumentExpression, substitutedFunctionalType)
|
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
|
// 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
|
val receiver = functionDescriptor.extensionReceiverParameter
|
||||||
if (extensionReceiverParameter != null) {
|
if (receiver != null) {
|
||||||
require(extensionReceiverParameter is ReceiverParameterDescriptorImpl) {
|
require(receiver is ReceiverParameterDescriptorImpl) {
|
||||||
"Extension receiver for anonymous function ($extensionReceiverParameter) should be 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 newValueType = resultSubstitutor.substituteKeepAnnotations(valueType)
|
||||||
|
|
||||||
val newReceiverValue = extensionReceiverParameter.value.replaceType(newValueType)
|
val newReceiverValue = receiver.value.replaceType(newValueType)
|
||||||
|
|
||||||
functionDescriptor.setExtensionReceiverParameter(
|
functionDescriptor.setExtensionReceiverParameter(
|
||||||
ReceiverParameterDescriptorImpl(extensionReceiverParameter.containingDeclaration, newReceiverValue)
|
ReceiverParameterDescriptorImpl(receiver.containingDeclaration, newReceiverValue, receiver.annotations)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -396,7 +396,7 @@ private fun IrFunction.generateDefaultsFunction(context: CommonBackendContext):
|
|||||||
} + syntheticParameters
|
} + syntheticParameters
|
||||||
|
|
||||||
descriptor.initialize(
|
descriptor.initialize(
|
||||||
/* receiverParameterType = */ extensionReceiverParameter?.type,
|
/* receiverParameterType = */ extensionReceiverParameter,
|
||||||
/* dispatchReceiverParameter = */ dispatchReceiverParameter,
|
/* dispatchReceiverParameter = */ dispatchReceiverParameter,
|
||||||
/* typeParameters = */ typeParameters.map {
|
/* typeParameters = */ typeParameters.map {
|
||||||
TypeParameterDescriptorImpl.createForFurtherModification(
|
TypeParameterDescriptorImpl.createForFurtherModification(
|
||||||
|
|||||||
+1
-1
@@ -520,7 +520,7 @@ class LocalDeclarationsLowering(
|
|||||||
val newValueParameters = createTransformedValueParameters(localFunctionContext, capturedValues)
|
val newValueParameters = createTransformedValueParameters(localFunctionContext, capturedValues)
|
||||||
|
|
||||||
newDescriptor.initialize(
|
newDescriptor.initialize(
|
||||||
oldDescriptor.extensionReceiverParameter?.type,
|
oldDescriptor.extensionReceiverParameter?.copy(newDescriptor),
|
||||||
newDispatchReceiverParameter,
|
newDispatchReceiverParameter,
|
||||||
newTypeParameters,
|
newTypeParameters,
|
||||||
newValueParameters.map { it.descriptor as ValueParameterDescriptor },
|
newValueParameters.map { it.descriptor as ValueParameterDescriptor },
|
||||||
|
|||||||
+1
-1
@@ -123,7 +123,7 @@ class BridgesConstruction(val context: JsIrBackendContext) : ClassLoweringPass {
|
|||||||
)
|
)
|
||||||
|
|
||||||
bridgeDescriptorForIrFunction.initialize(
|
bridgeDescriptorForIrFunction.initialize(
|
||||||
bridge.descriptor.extensionReceiverParameter?.returnType, containingClass.thisAsReceiverParameter,
|
bridge.descriptor.extensionReceiverParameter?.copy(bridge.descriptor), containingClass.thisAsReceiverParameter,
|
||||||
bridge.descriptor.typeParameters,
|
bridge.descriptor.typeParameters,
|
||||||
bridge.descriptor.valueParameters.map { it.copy(bridgeDescriptorForIrFunction, it.name, it.index) },
|
bridge.descriptor.valueParameters.map { it.copy(bridgeDescriptorForIrFunction, it.name, it.index) },
|
||||||
bridge.descriptor.returnType, bridge.descriptor.modality, function.visibility
|
bridge.descriptor.returnType, bridge.descriptor.modality, function.visibility
|
||||||
|
|||||||
+17
-4
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
|
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.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
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 newDispatchReceiverParameter = oldDispatchReceiverParameter?.let { descriptorSubstituteMap.getOrDefault(it, it) as ReceiverParameterDescriptor }
|
||||||
val newTypeParameters = oldDescriptor.typeParameters // TODO substitute types
|
val newTypeParameters = oldDescriptor.typeParameters // TODO substitute types
|
||||||
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
||||||
val newReceiverParameterType = substituteTypeAndTryGetCopied(oldDescriptor.extensionReceiverParameter?.type)
|
val newReceiverParameter = copyReceiverParameter(oldDescriptor.extensionReceiverParameter, this)
|
||||||
val newReturnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
|
val newReturnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
|
||||||
|
|
||||||
initialize(
|
initialize(
|
||||||
/* receiverParameterType = */ newReceiverParameterType,
|
/* extensionReceiverParameter = */ newReceiverParameter,
|
||||||
/* dispatchReceiverParameter = */ newDispatchReceiverParameter,
|
/* dispatchReceiverParameter = */ newDispatchReceiverParameter,
|
||||||
/* typeParameters = */ newTypeParameters,
|
/* typeParameters = */ newTypeParameters,
|
||||||
/* unsubstitutedValueParameters = */ newValueParameters,
|
/* unsubstitutedValueParameters = */ newValueParameters,
|
||||||
@@ -338,11 +339,11 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
|||||||
(descriptorSubstituteMap[oldDescriptor] as ClassConstructorDescriptorImpl).apply {
|
(descriptorSubstituteMap[oldDescriptor] as ClassConstructorDescriptorImpl).apply {
|
||||||
val newTypeParameters = oldDescriptor.typeParameters
|
val newTypeParameters = oldDescriptor.typeParameters
|
||||||
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
val newValueParameters = copyValueParameters(oldDescriptor.valueParameters, this)
|
||||||
val receiverParameterType = substituteTypeAndTryGetCopied(oldDescriptor.dispatchReceiverParameter?.type)
|
val newReceiverParameter = copyReceiverParameter(oldDescriptor.dispatchReceiverParameter, this)
|
||||||
val returnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
|
val returnType = substituteTypeAndTryGetCopied(oldDescriptor.returnType)
|
||||||
|
|
||||||
initialize(
|
initialize(
|
||||||
/* receiverParameterType = */ receiverParameterType,
|
/* extensionReceiverParameter = */ newReceiverParameter,
|
||||||
/* dispatchReceiverParameter = */ null, // For constructor there is no explicit dispatch receiver.
|
/* dispatchReceiverParameter = */ null, // For constructor there is no explicit dispatch receiver.
|
||||||
/* typeParameters = */ newTypeParameters,
|
/* typeParameters = */ newTypeParameters,
|
||||||
/* unsubstitutedValueParameters = */ newValueParameters,
|
/* unsubstitutedValueParameters = */ newValueParameters,
|
||||||
@@ -431,6 +432,18 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
|||||||
newDescriptor
|
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? {
|
private fun substituteTypeAndTryGetCopied(type: KotlinType?): KotlinType? {
|
||||||
val substitutedType = substituteType(type) ?: return null
|
val substitutedType = substituteType(type) ?: return null
|
||||||
val oldClassDescriptor = TypeUtils.getClassDescriptor(substitutedType) ?: return substitutedType
|
val oldClassDescriptor = TypeUtils.getClassDescriptor(substitutedType) ?: return substitutedType
|
||||||
|
|||||||
+3
-3
@@ -84,7 +84,7 @@ object JsSymbolBuilder {
|
|||||||
|
|
||||||
|
|
||||||
fun IrSimpleFunctionSymbol.initialize(
|
fun IrSimpleFunctionSymbol.initialize(
|
||||||
receiverParameterType: IrType? = null,
|
extensionReceiverParameter: ReceiverParameterDescriptor? = null,
|
||||||
dispatchParameterDescriptor: ReceiverParameterDescriptor? = null,
|
dispatchParameterDescriptor: ReceiverParameterDescriptor? = null,
|
||||||
typeParameters: List<TypeParameterDescriptor> = emptyList(),
|
typeParameters: List<TypeParameterDescriptor> = emptyList(),
|
||||||
valueParameters: List<ValueParameterDescriptor> = emptyList(),
|
valueParameters: List<ValueParameterDescriptor> = emptyList(),
|
||||||
@@ -93,7 +93,7 @@ fun IrSimpleFunctionSymbol.initialize(
|
|||||||
visibility: Visibility = Visibilities.LOCAL
|
visibility: Visibility = Visibilities.LOCAL
|
||||||
) = this.apply {
|
) = this.apply {
|
||||||
(descriptor as FunctionDescriptorImpl).initialize(
|
(descriptor as FunctionDescriptorImpl).initialize(
|
||||||
receiverParameterType?.toKotlinType(),
|
extensionReceiverParameter,
|
||||||
dispatchParameterDescriptor,
|
dispatchParameterDescriptor,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
valueParameters,
|
valueParameters,
|
||||||
@@ -101,4 +101,4 @@ fun IrSimpleFunctionSymbol.initialize(
|
|||||||
modality,
|
modality,
|
||||||
visibility
|
visibility
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ class JvmDescriptorsFactory(
|
|||||||
// Call the long version of `initialize()`, because otherwise default implementation inserts
|
// Call the long version of `initialize()`, because otherwise default implementation inserts
|
||||||
// an unwanted `dispatchReceiverParameter`
|
// an unwanted `dispatchReceiverParameter`
|
||||||
newDescriptor.initialize(
|
newDescriptor.initialize(
|
||||||
oldDescriptor.extensionReceiverParameter?.type,
|
oldDescriptor.extensionReceiverParameter?.copy(newDescriptor),
|
||||||
null,
|
null,
|
||||||
oldDescriptor.typeParameters,
|
oldDescriptor.typeParameters,
|
||||||
newValueParameters,
|
newValueParameters,
|
||||||
|
|||||||
+3
-2
@@ -197,7 +197,8 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
)
|
)
|
||||||
|
|
||||||
bridgeDescriptorForIrFunction.initialize(
|
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.valueParameters.map { it.copy(bridgeDescriptorForIrFunction, it.name, it.index) },
|
||||||
bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility
|
bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility
|
||||||
)
|
)
|
||||||
@@ -329,7 +330,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
)
|
)
|
||||||
|
|
||||||
delegationDescriptor.initialize(
|
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.valueParameters.map { it.copy(delegationDescriptor, it.name, it.index) },
|
||||||
descriptor.returnType, Modality.OPEN, descriptor.visibility
|
descriptor.returnType, Modality.OPEN, descriptor.visibility
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-3
@@ -8,11 +8,17 @@ package org.jetbrains.kotlin.backend.jvm.lower
|
|||||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
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.ClassConstructorDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
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.IrConstructorImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
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
|
// Call the long version of `initialize()`, because otherwise default implementation inserts
|
||||||
// an unwanted `dispatchReceiverParameter`.
|
// an unwanted `dispatchReceiverParameter`.
|
||||||
result.initialize(
|
result.initialize(
|
||||||
extensionReceiverParameter?.type,
|
extensionReceiverParameter?.copy(result),
|
||||||
dispatchReceiverParameter,
|
dispatchReceiverParameter,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
generateNewValueParameters(this, numDefaultParametersToExpect),
|
generateNewValueParameters(this, numDefaultParametersToExpect),
|
||||||
|
|||||||
+6
-4
@@ -18,8 +18,6 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
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.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
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.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
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
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -227,7 +229,7 @@ private fun makeJvmStaticFunctionSymbol(
|
|||||||
)
|
)
|
||||||
|
|
||||||
proxyDescriptorForIrFunction.initialize(
|
proxyDescriptorForIrFunction.initialize(
|
||||||
oldFunctionSymbol.descriptor.extensionReceiverParameter?.type,
|
oldFunctionSymbol.descriptor.extensionReceiverParameter?.copy(proxyDescriptorForIrFunction),
|
||||||
null,
|
null,
|
||||||
oldFunctionSymbol.descriptor.typeParameters,
|
oldFunctionSymbol.descriptor.typeParameters,
|
||||||
oldFunctionSymbol.descriptor.valueParameters.map { it.copy(proxyDescriptorForIrFunction, it.name, it.index) },
|
oldFunctionSymbol.descriptor.valueParameters.map { it.copy(proxyDescriptorForIrFunction, it.name, it.index) },
|
||||||
|
|||||||
+1
-2
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.ir.util.defaultType
|
|||||||
import org.jetbrains.kotlin.ir.util.usesDefaultArguments
|
import org.jetbrains.kotlin.ir.util.usesDefaultArguments
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
interface StubContext {
|
interface StubContext {
|
||||||
@@ -315,7 +314,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
private fun AccessorForConstructorDescriptor.constructorDescriptorWithMarker(marker: KotlinType) =
|
private fun AccessorForConstructorDescriptor.constructorDescriptorWithMarker(marker: KotlinType) =
|
||||||
ClassConstructorDescriptorImpl.createSynthesized(containingDeclaration, annotations, false, source).also {
|
ClassConstructorDescriptorImpl.createSynthesized(containingDeclaration, annotations, false, source).also {
|
||||||
it.initialize(
|
it.initialize(
|
||||||
DescriptorUtils.getReceiverParameterType(extensionReceiverParameter),
|
extensionReceiverParameter?.copy(this),
|
||||||
dispatchReceiverParameter,
|
dispatchReceiverParameter,
|
||||||
emptyList()/*TODO*/,
|
emptyList()/*TODO*/,
|
||||||
calleeDescriptor.valueParameters.map {
|
calleeDescriptor.valueParameters.map {
|
||||||
|
|||||||
+7
-1
@@ -22,7 +22,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.name.Name
|
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.classId
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.setSingleOverridden
|
import org.jetbrains.kotlin.resolve.descriptorUtil.setSingleOverridden
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
@@ -66,7 +68,11 @@ fun createSynthesizedInvokes(functions: Collection<FunctionDescriptor>): Collect
|
|||||||
|
|
||||||
private fun createSynthesizedFunctionWithFirstParameterAsReceiver(descriptor: FunctionDescriptor) =
|
private fun createSynthesizedFunctionWithFirstParameterAsReceiver(descriptor: FunctionDescriptor) =
|
||||||
descriptor.original.newCopyBuilder().apply {
|
descriptor.original.newCopyBuilder().apply {
|
||||||
setExtensionReceiverType(descriptor.original.valueParameters.first().type)
|
setExtensionReceiverParameter(
|
||||||
|
DescriptorFactory.createExtensionReceiverParameterForCallable(
|
||||||
|
descriptor.original, descriptor.original.valueParameters.first().type, Annotations.EMPTY
|
||||||
|
)
|
||||||
|
)
|
||||||
setValueParameters(
|
setValueParameters(
|
||||||
descriptor.original.valueParameters
|
descriptor.original.valueParameters
|
||||||
.drop(1)
|
.drop(1)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider;
|
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.ModuleDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
@@ -544,7 +545,8 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
|||||||
KotlinType thisType = makeType(contextType);
|
KotlinType thisType = makeType(contextType);
|
||||||
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(
|
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(
|
||||||
scopeWithImports.getOwnerDescriptor(),
|
scopeWithImports.getOwnerDescriptor(),
|
||||||
new TransientReceiver(thisType)
|
new TransientReceiver(thisType),
|
||||||
|
Annotations.Companion.getEMPTY()
|
||||||
);
|
);
|
||||||
|
|
||||||
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false,
|
LexicalScope scope = new LexicalScopeImpl(scopeWithImports, scopeWithImports.getOwnerDescriptor(), false,
|
||||||
|
|||||||
+7
-5
@@ -18,13 +18,11 @@ package org.jetbrains.kotlin.load.java.descriptors;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ClassConstructorDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -125,9 +123,13 @@ public class JavaClassConstructorDescriptor extends ClassConstructorDescriptorIm
|
|||||||
) {
|
) {
|
||||||
JavaClassConstructorDescriptor enhanced = createSubstitutedCopy(
|
JavaClassConstructorDescriptor enhanced = createSubstitutedCopy(
|
||||||
getContainingDeclaration(), /* original = */ null, getKind(), null, getAnnotations(), getSource());
|
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
|
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
|
||||||
enhanced.initialize(
|
enhanced.initialize(
|
||||||
enhancedReceiverType,
|
enhancedReceiver,
|
||||||
getDispatchReceiverParameter(),
|
getDispatchReceiverParameter(),
|
||||||
getTypeParameters(),
|
getTypeParameters(),
|
||||||
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), enhanced),
|
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), enhanced),
|
||||||
|
|||||||
+11
-4
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.util.OperatorChecks;
|
import org.jetbrains.kotlin.util.OperatorChecks;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public SimpleFunctionDescriptorImpl initialize(
|
public SimpleFunctionDescriptorImpl initialize(
|
||||||
@Nullable KotlinType receiverParameterType,
|
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@@ -93,8 +94,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
@Nullable Map<? extends UserDataKey<?>, ?> userData
|
@Nullable Map<? extends UserDataKey<?>, ?> userData
|
||||||
) {
|
) {
|
||||||
SimpleFunctionDescriptorImpl descriptor = super.initialize(
|
SimpleFunctionDescriptorImpl descriptor = super.initialize(
|
||||||
receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
||||||
unsubstitutedReturnType, modality, visibility, userData);
|
unsubstitutedReturnType, modality, visibility, userData
|
||||||
|
);
|
||||||
setOperator(OperatorChecks.INSTANCE.check(descriptor).isSuccess());
|
setOperator(OperatorChecks.INSTANCE.check(descriptor).isSuccess());
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
@@ -147,11 +149,16 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
List<ValueParameterDescriptor> enhancedValueParameters =
|
List<ValueParameterDescriptor> enhancedValueParameters =
|
||||||
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), this);
|
UtilKt.copyValueParameters(enhancedValueParametersData, getValueParameters(), this);
|
||||||
|
|
||||||
|
ReceiverParameterDescriptor enhancedReceiver =
|
||||||
|
enhancedReceiverType == null ? null : DescriptorFactory.createExtensionReceiverParameterForCallable(
|
||||||
|
this, enhancedReceiverType, Annotations.Companion.getEMPTY()
|
||||||
|
);
|
||||||
|
|
||||||
JavaMethodDescriptor enhancedMethod =
|
JavaMethodDescriptor enhancedMethod =
|
||||||
(JavaMethodDescriptor) newCopyBuilder()
|
(JavaMethodDescriptor) newCopyBuilder()
|
||||||
.setValueParameters(enhancedValueParameters)
|
.setValueParameters(enhancedValueParameters)
|
||||||
.setReturnType(enhancedReturnType)
|
.setReturnType(enhancedReturnType)
|
||||||
.setExtensionReceiverType(enhancedReceiverType)
|
.setExtensionReceiverParameter(enhancedReceiver)
|
||||||
.setDropOriginalInContainingParts()
|
.setDropOriginalInContainingParts()
|
||||||
.setPreserveSourceElement()
|
.setPreserveSourceElement()
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
+12
-8
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
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.PropertyDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
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.JavaMethod
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaValueParameter
|
import org.jetbrains.kotlin.load.java.structure.JavaValueParameter
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgument
|
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)
|
val effectiveSignature = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters.descriptors)
|
||||||
|
|
||||||
functionDescriptorImpl.initialize(
|
functionDescriptorImpl.initialize(
|
||||||
effectiveSignature.receiverType,
|
effectiveSignature.receiverType?.let {
|
||||||
getDispatchReceiverParameter(),
|
DescriptorFactory.createExtensionReceiverParameterForCallable(functionDescriptorImpl, it, Annotations.EMPTY)
|
||||||
effectiveSignature.typeParameters,
|
},
|
||||||
effectiveSignature.valueParameters,
|
getDispatchReceiverParameter(),
|
||||||
effectiveSignature.returnType,
|
effectiveSignature.typeParameters,
|
||||||
Modality.convertFromFlags(method.isAbstract, !method.isFinal),
|
effectiveSignature.valueParameters,
|
||||||
method.visibility,
|
effectiveSignature.returnType,
|
||||||
if (effectiveSignature.receiverType != null)
|
Modality.convertFromFlags(method.isAbstract, !method.isFinal),
|
||||||
|
method.visibility,
|
||||||
|
if (effectiveSignature.receiverType != null)
|
||||||
mapOf(JavaMethodDescriptor.ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER to valueParameters.descriptors.first())
|
mapOf(JavaMethodDescriptor.ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER to valueParameters.descriptors.first())
|
||||||
else
|
else
|
||||||
emptyMap<FunctionDescriptor.UserDataKey<ValueParameterDescriptor>, ValueParameterDescriptor>()
|
emptyMap<FunctionDescriptor.UserDataKey<ValueParameterDescriptor>, ValueParameterDescriptor>()
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
|
|||||||
CopyBuilder<D> setReturnType(@NotNull KotlinType type);
|
CopyBuilder<D> setReturnType(@NotNull KotlinType type);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
CopyBuilder<D> setExtensionReceiverType(@Nullable KotlinType type);
|
CopyBuilder<D> setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-1
@@ -22,11 +22,13 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
|||||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||||
|
|
||||||
public interface ReceiverParameterDescriptor extends ParameterDescriptor {
|
public interface ReceiverParameterDescriptor extends ParameterDescriptor {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
ReceiverValue getValue();
|
ReceiverValue getValue();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -33,8 +33,8 @@ import java.util.List;
|
|||||||
public abstract class AbstractReceiverParameterDescriptor extends DeclarationDescriptorImpl implements ReceiverParameterDescriptor {
|
public abstract class AbstractReceiverParameterDescriptor extends DeclarationDescriptorImpl implements ReceiverParameterDescriptor {
|
||||||
private static final Name RECEIVER_PARAMETER_NAME = Name.special("<this>");
|
private static final Name RECEIVER_PARAMETER_NAME = Name.special("<this>");
|
||||||
|
|
||||||
public AbstractReceiverParameterDescriptor() {
|
public AbstractReceiverParameterDescriptor(@NotNull Annotations annotations) {
|
||||||
super(Annotations.Companion.getEMPTY(), RECEIVER_PARAMETER_NAME);
|
super(annotations, RECEIVER_PARAMETER_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -58,7 +58,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
|||||||
if (substitutedType == null) return null;
|
if (substitutedType == null) return null;
|
||||||
if (substitutedType == getType()) return this;
|
if (substitutedType == getType()) return this;
|
||||||
|
|
||||||
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType));
|
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType), getAnnotations());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+24
-15
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsKt;
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsKt;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
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.types.*;
|
||||||
import org.jetbrains.kotlin.utils.SmartList;
|
import org.jetbrains.kotlin.utils.SmartList;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public FunctionDescriptorImpl initialize(
|
public FunctionDescriptorImpl initialize(
|
||||||
@Nullable KotlinType receiverParameterType,
|
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@@ -79,7 +79,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
||||||
this.modality = modality;
|
this.modality = modality;
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
this.extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverParameterType);
|
this.extensionReceiverParameter = extensionReceiverParameter;
|
||||||
this.dispatchReceiverParameter = dispatchReceiverParameter;
|
this.dispatchReceiverParameter = dispatchReceiverParameter;
|
||||||
|
|
||||||
for (int i = 0; i < typeParameters.size(); ++i) {
|
for (int i = 0; i < typeParameters.size(); ++i) {
|
||||||
@@ -350,7 +350,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
protected @Nullable FunctionDescriptor original = null;
|
protected @Nullable FunctionDescriptor original = null;
|
||||||
protected @NotNull Kind kind;
|
protected @NotNull Kind kind;
|
||||||
protected @NotNull List<ValueParameterDescriptor> newValueParameterDescriptors;
|
protected @NotNull List<ValueParameterDescriptor> newValueParameterDescriptors;
|
||||||
protected @Nullable KotlinType newExtensionReceiverParameterType;
|
protected @Nullable ReceiverParameterDescriptor newExtensionReceiverParameter;
|
||||||
protected @Nullable ReceiverParameterDescriptor dispatchReceiverParameter = FunctionDescriptorImpl.this.dispatchReceiverParameter;
|
protected @Nullable ReceiverParameterDescriptor dispatchReceiverParameter = FunctionDescriptorImpl.this.dispatchReceiverParameter;
|
||||||
protected @NotNull KotlinType newReturnType;
|
protected @NotNull KotlinType newReturnType;
|
||||||
protected @Nullable Name name;
|
protected @Nullable Name name;
|
||||||
@@ -373,7 +373,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
@NotNull Visibility newVisibility,
|
@NotNull Visibility newVisibility,
|
||||||
@NotNull Kind kind,
|
@NotNull Kind kind,
|
||||||
@NotNull List<ValueParameterDescriptor> newValueParameterDescriptors,
|
@NotNull List<ValueParameterDescriptor> newValueParameterDescriptors,
|
||||||
@Nullable KotlinType newExtensionReceiverParameterType,
|
@Nullable ReceiverParameterDescriptor newExtensionReceiverParameter,
|
||||||
@NotNull KotlinType newReturnType,
|
@NotNull KotlinType newReturnType,
|
||||||
@Nullable Name name
|
@Nullable Name name
|
||||||
) {
|
) {
|
||||||
@@ -383,7 +383,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
this.newVisibility = newVisibility;
|
this.newVisibility = newVisibility;
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.newValueParameterDescriptors = newValueParameterDescriptors;
|
this.newValueParameterDescriptors = newValueParameterDescriptors;
|
||||||
this.newExtensionReceiverParameterType = newExtensionReceiverParameterType;
|
this.newExtensionReceiverParameter = newExtensionReceiverParameter;
|
||||||
this.newReturnType = newReturnType;
|
this.newReturnType = newReturnType;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@@ -453,8 +453,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CopyConfiguration setExtensionReceiverType(@Nullable KotlinType type) {
|
public CopyConfiguration setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter) {
|
||||||
this.newExtensionReceiverParameterType = type;
|
this.newExtensionReceiverParameter = extensionReceiverParameter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +567,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
return new CopyConfiguration(
|
return new CopyConfiguration(
|
||||||
substitutor.getSubstitution(),
|
substitutor.getSubstitution(),
|
||||||
getContainingDeclaration(), getModality(), getVisibility(), getKind(), getValueParameters(),
|
getContainingDeclaration(), getModality(), getVisibility(), getKind(), getValueParameters(),
|
||||||
getExtensionReceiverParameterType(), getReturnType(), null);
|
getExtensionReceiverParameter(), getReturnType(), null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -594,14 +595,22 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
);
|
);
|
||||||
if (substitutor == null) return null;
|
if (substitutor == null) return null;
|
||||||
|
|
||||||
KotlinType substitutedReceiverParameterType = null;
|
ReceiverParameterDescriptor substitutedReceiverParameter = null;
|
||||||
if (configuration.newExtensionReceiverParameterType != null) {
|
if (configuration.newExtensionReceiverParameter != null) {
|
||||||
substitutedReceiverParameterType = substitutor.substitute(configuration.newExtensionReceiverParameterType, Variance.IN_VARIANCE);
|
KotlinType substitutedExtensionReceiverType =
|
||||||
if (substitutedReceiverParameterType == null) {
|
substitutor.substitute(configuration.newExtensionReceiverParameter.getType(), Variance.IN_VARIANCE);
|
||||||
|
if (substitutedExtensionReceiverType == null) {
|
||||||
return 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;
|
ReceiverParameterDescriptor substitutedExpectedThis = null;
|
||||||
@@ -644,7 +653,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
}
|
}
|
||||||
|
|
||||||
substitutedDescriptor.initialize(
|
substitutedDescriptor.initialize(
|
||||||
substitutedReceiverParameterType,
|
substitutedReceiverParameter,
|
||||||
substitutedExpectedThis,
|
substitutedExpectedThis,
|
||||||
substitutedTypeParameters,
|
substitutedTypeParameters,
|
||||||
substitutedValueParameters,
|
substitutedValueParameters,
|
||||||
|
|||||||
+9
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.descriptors.impl;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
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.ImplicitClassReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
|
|
||||||
@@ -27,6 +29,7 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame
|
|||||||
private final ImplicitClassReceiver receiverValue;
|
private final ImplicitClassReceiver receiverValue;
|
||||||
|
|
||||||
public LazyClassReceiverParameterDescriptor(@NotNull ClassDescriptor descriptor) {
|
public LazyClassReceiverParameterDescriptor(@NotNull ClassDescriptor descriptor) {
|
||||||
|
super(Annotations.Companion.getEMPTY());
|
||||||
this.descriptor = descriptor;
|
this.descriptor = descriptor;
|
||||||
this.receiverValue = new ImplicitClassReceiver(descriptor, null);
|
this.receiverValue = new ImplicitClassReceiver(descriptor, null);
|
||||||
}
|
}
|
||||||
@@ -43,6 +46,12 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame
|
|||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "class " + descriptor.getName() + "::this";
|
return "class " + descriptor.getName() + "::this";
|
||||||
|
|||||||
+2
-1
@@ -112,7 +112,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@Nullable KotlinType receiverType
|
@Nullable KotlinType receiverType
|
||||||
) {
|
) {
|
||||||
ReceiverParameterDescriptor extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType);
|
ReceiverParameterDescriptor extensionReceiverParameter =
|
||||||
|
DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType, Annotations.Companion.getEMPTY());
|
||||||
setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter);
|
setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -19,13 +19,19 @@ package org.jetbrains.kotlin.descriptors.impl;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
|
|
||||||
public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor {
|
public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor {
|
||||||
private final DeclarationDescriptor containingDeclaration;
|
private final DeclarationDescriptor containingDeclaration;
|
||||||
private final ReceiverValue value;
|
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.containingDeclaration = containingDeclaration;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@@ -41,4 +47,10 @@ public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDe
|
|||||||
public DeclarationDescriptor getContainingDeclaration() {
|
public DeclarationDescriptor getContainingDeclaration() {
|
||||||
return containingDeclaration;
|
return containingDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public ReceiverParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||||
|
return new ReceiverParameterDescriptorImpl(newOwner, value, getAnnotations());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -53,7 +53,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public SimpleFunctionDescriptorImpl initialize(
|
public SimpleFunctionDescriptorImpl initialize(
|
||||||
@Nullable KotlinType receiverParameterType,
|
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@@ -61,13 +61,13 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
@Nullable Modality modality,
|
@Nullable Modality modality,
|
||||||
@NotNull Visibility visibility
|
@NotNull Visibility visibility
|
||||||
) {
|
) {
|
||||||
return initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
return initialize(extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
||||||
unsubstitutedReturnType, modality, visibility, null);
|
unsubstitutedReturnType, modality, visibility, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public SimpleFunctionDescriptorImpl initialize(
|
public SimpleFunctionDescriptorImpl initialize(
|
||||||
@Nullable KotlinType receiverParameterType,
|
@Nullable ReceiverParameterDescriptor extensionReceiverParameter,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@@ -76,7 +76,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility,
|
||||||
@Nullable Map<? extends UserDataKey<?>, ?> userData
|
@Nullable Map<? extends UserDataKey<?>, ?> userData
|
||||||
) {
|
) {
|
||||||
super.initialize(receiverParameterType, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
super.initialize(extensionReceiverParameter, dispatchReceiverParameter, typeParameters, unsubstitutedValueParameters,
|
||||||
unsubstitutedReturnType, modality, visibility);
|
unsubstitutedReturnType, modality, visibility);
|
||||||
|
|
||||||
if (userData != null && !userData.isEmpty()) {
|
if (userData != null && !userData.isEmpty()) {
|
||||||
|
|||||||
+8
-3
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.storage.getValue
|
import org.jetbrains.kotlin.storage.getValue
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
@@ -192,12 +193,16 @@ class TypeAliasConstructorDescriptorImpl private constructor(
|
|||||||
|
|
||||||
val returnType = substitutedConstructor.returnType.unwrap().lowerIfFlexible().withAbbreviation(typeAliasDescriptor.defaultType)
|
val returnType = substitutedConstructor.returnType.unwrap().lowerIfFlexible().withAbbreviation(typeAliasDescriptor.defaultType)
|
||||||
|
|
||||||
val receiverParameterType = constructor.dispatchReceiverParameter?.let {
|
val receiverParameter = constructor.dispatchReceiverParameter?.let {
|
||||||
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT)
|
DescriptorFactory.createExtensionReceiverParameterForCallable(
|
||||||
|
typeAliasConstructor,
|
||||||
|
substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT),
|
||||||
|
Annotations.EMPTY
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
typeAliasConstructor.initialize(
|
typeAliasConstructor.initialize(
|
||||||
receiverParameterType,
|
receiverParameter,
|
||||||
null,
|
null,
|
||||||
typeAliasDescriptor.declaredTypeParameters,
|
typeAliasDescriptor.declaredTypeParameters,
|
||||||
valueParameters,
|
valueParameters,
|
||||||
|
|||||||
@@ -168,10 +168,11 @@ public class DescriptorFactory {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable(
|
public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable(
|
||||||
@NotNull CallableDescriptor owner,
|
@NotNull CallableDescriptor owner,
|
||||||
@Nullable KotlinType receiverParameterType
|
@Nullable KotlinType receiverParameterType,
|
||||||
|
@NotNull Annotations annotations
|
||||||
) {
|
) {
|
||||||
return receiverParameterType == null
|
return receiverParameterType == null
|
||||||
? null
|
? null
|
||||||
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType, null));
|
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType, null), annotations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -123,7 +123,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public CopyBuilder<SimpleFunctionDescriptor> setExtensionReceiverType(@Nullable KotlinType type) {
|
public CopyBuilder<SimpleFunctionDescriptor> setExtensionReceiverParameter(@Nullable ReceiverParameterDescriptor extensionReceiverParameter) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -154,7 +154,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun DeserializedSimpleFunctionDescriptor.initializeWithCoroutinesExperimentalityStatus(
|
private fun DeserializedSimpleFunctionDescriptor.initializeWithCoroutinesExperimentalityStatus(
|
||||||
receiverParameterType: KotlinType?,
|
extensionReceiverParameter: ReceiverParameterDescriptor?,
|
||||||
dispatchReceiverParameter: ReceiverParameterDescriptor?,
|
dispatchReceiverParameter: ReceiverParameterDescriptor?,
|
||||||
typeParameters: List<TypeParameterDescriptor>,
|
typeParameters: List<TypeParameterDescriptor>,
|
||||||
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
|
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
|
||||||
@@ -165,7 +165,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
isSuspend: Boolean
|
isSuspend: Boolean
|
||||||
) {
|
) {
|
||||||
initialize(
|
initialize(
|
||||||
receiverParameterType,
|
extensionReceiverParameter,
|
||||||
dispatchReceiverParameter,
|
dispatchReceiverParameter,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
unsubstitutedValueParameters,
|
unsubstitutedValueParameters,
|
||||||
@@ -174,7 +174,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
visibility,
|
visibility,
|
||||||
userDataMap,
|
userDataMap,
|
||||||
computeExperimentalityModeForFunctions(
|
computeExperimentalityModeForFunctions(
|
||||||
receiverParameterType,
|
extensionReceiverParameter,
|
||||||
unsubstitutedValueParameters,
|
unsubstitutedValueParameters,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
unsubstitutedReturnType,
|
unsubstitutedReturnType,
|
||||||
@@ -184,7 +184,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun DeserializedCallableMemberDescriptor.computeExperimentalityModeForFunctions(
|
private fun DeserializedCallableMemberDescriptor.computeExperimentalityModeForFunctions(
|
||||||
extensionReceiverType: KotlinType?,
|
extensionReceiverParameter: ReceiverParameterDescriptor?,
|
||||||
parameters: Collection<ValueParameterDescriptor>,
|
parameters: Collection<ValueParameterDescriptor>,
|
||||||
typeParameters: Collection<TypeParameterDescriptor>,
|
typeParameters: Collection<TypeParameterDescriptor>,
|
||||||
returnType: KotlinType?,
|
returnType: KotlinType?,
|
||||||
@@ -193,7 +193,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
if (!versionAndReleaseCoroutinesMismatch()) return CoroutinesCompatibilityMode.COMPATIBLE
|
if (!versionAndReleaseCoroutinesMismatch()) return CoroutinesCompatibilityMode.COMPATIBLE
|
||||||
if (fqNameOrNull() == KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME) 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 (returnType?.containsSuspendFunctionType() == true) return CoroutinesCompatibilityMode.INCOMPATIBLE
|
||||||
if (typeParameters.any { typeParameter -> typeParameter.upperBounds.any { it.containsSuspendFunctionType() } }) {
|
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)
|
val local = c.childContext(function, proto.typeParameterList)
|
||||||
|
|
||||||
function.initializeWithCoroutinesExperimentalityStatus(
|
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(),
|
getDispatchReceiverParameter(),
|
||||||
local.typeDeserializer.ownTypeParameters,
|
local.typeDeserializer.ownTypeParameters,
|
||||||
local.memberDeserializer.valueParameters(proto.valueParameterList, proto, AnnotatedCallableKind.FUNCTION),
|
local.memberDeserializer.valueParameters(proto.valueParameterList, proto, AnnotatedCallableKind.FUNCTION),
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ class DeserializedSimpleFunctionDescriptor(
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
fun initialize(
|
fun initialize(
|
||||||
receiverParameterType: KotlinType?,
|
extensionReceiverParameter: ReceiverParameterDescriptor?,
|
||||||
dispatchReceiverParameter: ReceiverParameterDescriptor?,
|
dispatchReceiverParameter: ReceiverParameterDescriptor?,
|
||||||
typeParameters: List<TypeParameterDescriptor>,
|
typeParameters: List<TypeParameterDescriptor>,
|
||||||
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
|
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
|
||||||
@@ -87,7 +87,7 @@ class DeserializedSimpleFunctionDescriptor(
|
|||||||
isExperimentalCoroutineInReleaseEnvironment: DeserializedMemberDescriptor.CoroutinesCompatibilityMode
|
isExperimentalCoroutineInReleaseEnvironment: DeserializedMemberDescriptor.CoroutinesCompatibilityMode
|
||||||
): SimpleFunctionDescriptorImpl {
|
): SimpleFunctionDescriptorImpl {
|
||||||
return super.initialize(
|
return super.initialize(
|
||||||
receiverParameterType,
|
extensionReceiverParameter,
|
||||||
dispatchReceiverParameter,
|
dispatchReceiverParameter,
|
||||||
typeParameters,
|
typeParameters,
|
||||||
unsubstitutedValueParameters,
|
unsubstitutedValueParameters,
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
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.core.ShortenReferences
|
||||||
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.load.java.NOT_NULL_ANNOTATIONS
|
import org.jetbrains.kotlin.load.java.NOT_NULL_ANNOTATIONS
|
||||||
@@ -219,7 +219,7 @@ class ChangeMemberFunctionSignatureFix private constructor(
|
|||||||
|
|
||||||
return descriptor.apply {
|
return descriptor.apply {
|
||||||
initialize(
|
initialize(
|
||||||
function.extensionReceiverParameter?.type, function.dispatchReceiverParameter,
|
function.extensionReceiverParameter?.copy(this), function.dispatchReceiverParameter,
|
||||||
function.typeParameters, parameters, function.returnType, function.modality, function.visibility
|
function.typeParameters, parameters, function.returnType, function.modality, function.visibility
|
||||||
)
|
)
|
||||||
isOperator = function.isOperator
|
isOperator = function.isOperator
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ internal class ChangeMethodParameters(
|
|||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
).apply {
|
).apply {
|
||||||
initialize(
|
initialize(
|
||||||
functionDescriptor.extensionReceiverParameter?.type,
|
functionDescriptor.extensionReceiverParameter?.copy(this),
|
||||||
functionDescriptor.dispatchReceiverParameter,
|
functionDescriptor.dispatchReceiverParameter,
|
||||||
functionDescriptor.typeParameters,
|
functionDescriptor.typeParameters,
|
||||||
request.withIndex().map { (index, parameter) ->
|
request.withIndex().map { (index, parameter) ->
|
||||||
|
|||||||
+5
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
|||||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||||
import org.jetbrains.kotlin.name.Name
|
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.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||||
@@ -46,8 +47,10 @@ internal fun genClearCacheFunction(packageFragmentDescriptor: PackageFragmentDes
|
|||||||
SourceElement.NO_SOURCE) {}
|
SourceElement.NO_SOURCE) {}
|
||||||
|
|
||||||
val unitType = packageFragmentDescriptor.builtIns.unitType
|
val unitType = packageFragmentDescriptor.builtIns.unitType
|
||||||
function.initialize(receiverType, null, emptyList(), emptyList(), unitType, Modality.FINAL, Visibilities.PUBLIC)
|
return function.initialize(
|
||||||
return function
|
DescriptorFactory.createExtensionReceiverParameterForCallable(function, receiverType, Annotations.EMPTY),
|
||||||
|
null, emptyList(), emptyList(), unitType, Modality.FINAL, Visibilities.PUBLIC
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun genPropertyForWidget(
|
internal fun genPropertyForWidget(
|
||||||
|
|||||||
Reference in New Issue
Block a user