Drop PropertyDescriptorImpl.setType that takes KotlinType
Only use the other setType that takes an instance of ReceiverParameterDescriptor. This will make sure that call sites can use correct receiver annotations
This commit is contained in:
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
@@ -95,7 +96,10 @@ open class AccessorForPropertyDescriptor private constructor(
|
||||
)
|
||||
|
||||
init {
|
||||
setType(propertyType, emptyList<TypeParameterDescriptorImpl>(), dispatchReceiverParameter, receiverType)
|
||||
setType(
|
||||
propertyType, emptyList<TypeParameterDescriptorImpl>(), dispatchReceiverParameter,
|
||||
DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType, Annotations.EMPTY)
|
||||
)
|
||||
|
||||
val getterDescriptor =
|
||||
if (isWithSyntheticGetterAccessor) Getter(this, accessorKind) else calleeDescriptor.getter as PropertyGetterDescriptorImpl?
|
||||
|
||||
+5
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
@@ -337,7 +338,10 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
|
||||
val propertyType = typeSubstitutor.safeSubstitute(type, Variance.INVARIANT)
|
||||
val receiverType = typeSubstitutor.safeSubstitute(ownerClass.defaultType, Variance.INVARIANT)
|
||||
descriptor.setType(propertyType, typeParameters, null, receiverType)
|
||||
descriptor.setType(
|
||||
propertyType, typeParameters, null,
|
||||
DescriptorFactory.createExtensionReceiverParameterForCallable(descriptor, receiverType, Annotations.EMPTY)
|
||||
)
|
||||
|
||||
val getter = PropertyGetterDescriptorImpl(
|
||||
descriptor,
|
||||
|
||||
@@ -1230,9 +1230,7 @@ public class DescriptorResolver {
|
||||
false
|
||||
);
|
||||
propertyWrapper.setDescriptor(propertyDescriptor);
|
||||
propertyDescriptor.setType(
|
||||
type, Collections.emptyList(), getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null
|
||||
);
|
||||
propertyDescriptor.setType(type, Collections.emptyList(), getDispatchReceiverParameterIfNeeded(classDescriptor), null);
|
||||
|
||||
Annotations setterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER);
|
||||
Annotations getterAnnotations = new CompositeAnnotations(CollectionsKt.listOf(
|
||||
|
||||
@@ -179,7 +179,7 @@ class LocalVariableResolver(
|
||||
type = variableTypeAndInitializerResolver.resolveType(propertyDescriptor, scope, variable, dataFlowInfo, trace, local = true)
|
||||
|
||||
val receiverParameter = (containingDeclaration as ScriptDescriptor).thisAsReceiverParameter
|
||||
propertyDescriptor.setType(type, emptyList<TypeParameterDescriptor>(), receiverParameter, null as KotlinType?)
|
||||
propertyDescriptor.setType(type, emptyList<TypeParameterDescriptor>(), receiverParameter, null)
|
||||
initializeWithDefaultGetterSetter(propertyDescriptor)
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor)
|
||||
result = propertyDescriptor
|
||||
|
||||
@@ -104,7 +104,7 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
||||
dynamicType,
|
||||
createTypeParameters(propertyDescriptor, call),
|
||||
createDynamicDispatchReceiverParameter(propertyDescriptor),
|
||||
null as KotlinType?
|
||||
null
|
||||
)
|
||||
|
||||
val getter = DescriptorFactory.createDefaultGetter(propertyDescriptor, Annotations.EMPTY)
|
||||
|
||||
+5
-3
@@ -7,10 +7,12 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors.script
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyScriptDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class ScriptEnvironmentPropertyDescriptor(
|
||||
name: Name,
|
||||
@@ -32,7 +34,7 @@ class ScriptEnvironmentPropertyDescriptor(
|
||||
/* isDelegated = */ false
|
||||
) {
|
||||
init {
|
||||
setType(typeDescriptor.defaultType, emptyList<TypeParameterDescriptorImpl>(), receiver, null as KotlinType?)
|
||||
setType(typeDescriptor.defaultType, emptyList(), receiver, null)
|
||||
initialize(
|
||||
makePropertyGetterDescriptor(),
|
||||
if (!isVar) null else makePropertySetterDescriptor()
|
||||
|
||||
+2
-8
@@ -53,17 +53,11 @@ class JsDescriptorsFactory : DescriptorsFactory {
|
||||
false,
|
||||
false
|
||||
).apply {
|
||||
setType(
|
||||
outerClass.defaultType.toKotlinType(),
|
||||
emptyList(),
|
||||
innerClass.descriptor.thisAsReceiverParameter,
|
||||
null as? ReceiverParameterDescriptor
|
||||
)
|
||||
setType(outerClass.defaultType.toKotlinType(), emptyList(), innerClass.descriptor.thisAsReceiverParameter, null)
|
||||
initialize(null, null)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun getInnerClassConstructorWithOuterThisParameter(innerClassConstructor: IrConstructor): IrConstructorSymbol {
|
||||
val innerClass = innerClassConstructor.parent as IrClass
|
||||
assert(innerClass.isInner) { "Class is not inner: $innerClass" }
|
||||
@@ -109,7 +103,7 @@ class JsDescriptorsFactory : DescriptorsFactory {
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isExpect = */ false, /* isActual = */ false, /* isExternal = */ false, /* isDelegated = */ false
|
||||
).apply {
|
||||
setType(objectDescriptor.defaultType, emptyList(), null, null as ReceiverParameterDescriptor)
|
||||
setType(objectDescriptor.defaultType, emptyList(), null, null)
|
||||
initialize(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -173,8 +173,7 @@ class JsSharedVariablesManager(val builtIns: KotlinBuiltIns, val jsInterinalPack
|
||||
false
|
||||
)
|
||||
|
||||
|
||||
desc.setType(builtIns.anyType, emptyList(), closureBoxTypeDescriptor.thisAsReceiverParameter, null as ReceiverParameterDescriptor?)
|
||||
desc.setType(builtIns.anyType, emptyList(), closureBoxTypeDescriptor.thisAsReceiverParameter, null)
|
||||
desc.initialize(null, null)
|
||||
|
||||
return desc
|
||||
|
||||
+2
-1
@@ -361,7 +361,8 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
||||
/* outType = */ substituteTypeAndTryGetCopied(oldDescriptor.type)!!,
|
||||
/* typeParameters = */ oldDescriptor.typeParameters,
|
||||
/* dispatchReceiverParameter = */ (containingDeclaration as ClassDescriptor).thisAsReceiverParameter,
|
||||
/* receiverType = */ substituteTypeAndTryGetCopied(oldDescriptor.extensionReceiverParameter?.type))
|
||||
/* extensionReceiverParameter= */ copyReceiverParameter(oldDescriptor.extensionReceiverParameter, this)
|
||||
)
|
||||
|
||||
initialize(
|
||||
/* getter = */ oldDescriptor.getter?.let { copyPropertyGetterDescriptor(it, this) },
|
||||
|
||||
+1
-1
@@ -474,7 +474,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
||||
/* outType = */ superNameProperty.type,
|
||||
/* typeParameters = */ superNameProperty.typeParameters,
|
||||
/* dispatchReceiverParameter = */ superNameProperty.dispatchReceiverParameter,
|
||||
/* receiverType = */ superNameProperty.extensionReceiverParameter?.type
|
||||
/* extensionReceiverParameter= */ superNameProperty.extensionReceiverParameter
|
||||
)
|
||||
//overriddenDescriptors += superNameProperty.getter
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import java.lang.UnsupportedOperationException
|
||||
|
||||
interface IrDelegateDescriptor : PropertyDescriptor
|
||||
|
||||
@@ -68,13 +67,7 @@ abstract class IrDelegateDescriptorBase(
|
||||
/* isDelegated = */ true
|
||||
) {
|
||||
init {
|
||||
val typeParameters: List<TypeParameterDescriptor> = emptyList()
|
||||
val extensionReceiverParameter: ReceiverParameterDescriptor? = null
|
||||
val dispatchReceiverParameter =
|
||||
if (containingDeclaration is ClassDescriptor)
|
||||
containingDeclaration.thisAsReceiverParameter
|
||||
else null
|
||||
setType(delegateType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter)
|
||||
setType(delegateType, emptyList(), (containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter, null)
|
||||
}
|
||||
|
||||
final override fun setOutType(outType: KotlinType?) {
|
||||
|
||||
@@ -15,21 +15,14 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.toIrType
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
/**
|
||||
* Binds the arguments explicitly represented in the IR to the parameters of the accessed function.
|
||||
@@ -363,8 +356,7 @@ fun createField(
|
||||
).apply {
|
||||
initialize(null, null)
|
||||
|
||||
val receiverType: KotlinType? = null
|
||||
setType(type.toKotlinType(), emptyList(), owner.thisAsReceiverParameter, receiverType)
|
||||
setType(type.toKotlinType(), emptyList(), owner.thisAsReceiverParameter, null)
|
||||
}
|
||||
|
||||
return IrFieldImpl(startOffset, endOffset, origin, descriptor, type)
|
||||
|
||||
Reference in New Issue
Block a user