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:
Alexander Udalov
2018-08-08 17:46:00 +02:00
parent 34c033bcaf
commit ab441dcd96
19 changed files with 53 additions and 67 deletions
@@ -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)
}
}
@@ -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
@@ -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) },
@@ -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)