From ab441dcd96f795d45c2241c823f82e1405a6b36c Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 8 Aug 2018 17:46:00 +0200 Subject: [PATCH] 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 --- .../codegen/AccessorForPropertyDescriptor.kt | 6 ++++- .../synthetic/JavaSyntheticPropertiesScope.kt | 6 ++++- .../kotlin/resolve/DescriptorResolver.java | 4 +-- .../kotlin/resolve/LocalVariableResolver.kt | 2 +- .../resolve/calls/tasks/dynamicCalls.kt | 2 +- .../ScriptEnvironmentPropertyDescriptor.kt | 8 +++--- .../ir/backend/js/JsDescriptorsFactory.kt | 10 ++----- .../ir/backend/js/JsSharedVariablesManager.kt | 3 +-- .../inline/DeepCopyIrTreeWithDescriptors.kt | 3 ++- .../jvm/lower/CallableReferenceLowering.kt | 2 +- .../ir/descriptors/IrDelegateDescriptor.kt | 9 +------ .../org/jetbrains/kotlin/ir/util/IrUtils.kt | 12 ++------- .../descriptors/JavaPropertyDescriptor.java | 8 +++++- .../descriptors/LazyJavaClassMemberScope.kt | 4 +-- .../java/lazy/descriptors/LazyJavaScope.kt | 2 +- .../impl/PropertyDescriptorImpl.java | 26 +++++++------------ .../jetbrains/kotlin/types/ErrorUtils.java | 6 +---- .../deserialization/MemberDeserializer.kt | 4 ++- .../res/syntheticDescriptorGeneration.kt | 3 ++- 19 files changed, 53 insertions(+), 67 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.kt index 0b78415c7e6..c3119bd0858 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.kt @@ -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(), dispatchReceiverParameter, receiverType) + setType( + propertyType, emptyList(), dispatchReceiverParameter, + DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType, Annotations.EMPTY) + ) val getterDescriptor = if (isWithSyntheticGetterAccessor) Getter(this, accessorKind) else calleeDescriptor.getter as PropertyGetterDescriptorImpl? diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index d9e91b8e40c..c6da3ea1af0 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -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, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 53f855eeb51..805d4ff7b63 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -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( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LocalVariableResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LocalVariableResolver.kt index 984ce27be53..29b2e0a8a1c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LocalVariableResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LocalVariableResolver.kt @@ -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(), receiverParameter, null as KotlinType?) + propertyDescriptor.setType(type, emptyList(), receiverParameter, null) initializeWithDefaultGetterSetter(propertyDescriptor) trace.record(BindingContext.VARIABLE, variable, propertyDescriptor) result = propertyDescriptor diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index 50356d9bd7c..9f7e84363ee 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -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) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/script/ScriptEnvironmentPropertyDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/script/ScriptEnvironmentPropertyDescriptor.kt index 763e221a410..cef66e7238c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/script/ScriptEnvironmentPropertyDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/script/ScriptEnvironmentPropertyDescriptor.kt @@ -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(), receiver, null as KotlinType?) + setType(typeDescriptor.defaultType, emptyList(), receiver, null) initialize( makePropertyGetterDescriptor(), if (!isVar) null else makePropertySetterDescriptor() diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDescriptorsFactory.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDescriptorsFactory.kt index b741bbc1b9a..76125f0e237 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDescriptorsFactory.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDescriptorsFactory.kt @@ -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) } } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt index bdb686138c9..1289677a1e4 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt @@ -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 diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt index cb118a9f688..268a612656f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt @@ -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) }, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt index b4d894ca9ee..016b33fa330 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt @@ -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 } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt index 0c1e0e23273..b670bc147a4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt @@ -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 = 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?) { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt index f16b4d8dc17..10d10835680 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt @@ -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) diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index 7356124277b..031c4db26f5 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl; import org.jetbrains.kotlin.load.java.typeEnhancement.TypeEnhancementKt; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -138,11 +139,16 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja enhanced.setOverriddenDescriptors(getOverriddenDescriptors()); + ReceiverParameterDescriptor enhancedReceiver = + enhancedReceiverType == null ? null : DescriptorFactory.createExtensionReceiverParameterForCallable( + this, enhancedReceiverType, Annotations.Companion.getEMPTY() + ); + enhanced.setType( enhancedReturnType, getTypeParameters(), // TODO getDispatchReceiverParameter(), - enhancedReceiverType + enhancedReceiver ); return enhanced; } diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index b2709d959b5..b742f17b709 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -489,7 +489,7 @@ class LazyJavaClassMemberScope( propertyDescriptor.initialize(getter, null) val returnType = givenType ?: computeMethodReturnType(method, c.childForMethod(propertyDescriptor, method)) - propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KotlinType?) + propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null) getter.initialize(returnType) return propertyDescriptor @@ -519,7 +519,7 @@ class LazyJavaClassMemberScope( /* isStaticFinal = */ false ) - propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KotlinType?) + propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null) val getter = DescriptorFactory.createGetter( propertyDescriptor, getterMethod.annotations, /* isDefault = */false, diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 31b23f4e952..b6c92e70408 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -275,7 +275,7 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS val propertyType = getPropertyType(field) - propertyDescriptor.setType(propertyType, listOf(), getDispatchReceiverParameter(), null as KotlinType?) + propertyDescriptor.setType(propertyType, listOf(), getDispatchReceiverParameter(), null) if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.type)) { propertyDescriptor.setCompileTimeInitializer( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java index 4dfc7a86e89..2052a6bb6d7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.resolve.DescriptorFactory; +import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver; import org.jetbrains.kotlin.types.*; import org.jetbrains.kotlin.utils.SmartSet; @@ -106,17 +106,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp isExpect, isActual, isExternal, isDelegated); } - public void setType( - @NotNull KotlinType outType, - @ReadOnly @NotNull List typeParameters, - @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, - @Nullable KotlinType receiverType - ) { - ReceiverParameterDescriptor extensionReceiverParameter = - DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType, Annotations.Companion.getEMPTY()); - setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter); - } - public void setType( @NotNull KotlinType outType, @ReadOnly @NotNull List typeParameters, @@ -366,16 +355,21 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp substitutedDispatchReceiver = null; } - KotlinType substitutedReceiverType; + ReceiverParameterDescriptor substitutedExtensionReceiver; if (extensionReceiverParameter != null) { - substitutedReceiverType = substitutor.substitute(extensionReceiverParameter.getType(), Variance.IN_VARIANCE); + KotlinType substitutedReceiverType = substitutor.substitute(extensionReceiverParameter.getType(), Variance.IN_VARIANCE); if (substitutedReceiverType == null) return null; + substitutedExtensionReceiver = new ReceiverParameterDescriptorImpl( + substitutedDescriptor, + new ExtensionReceiver(substitutedDescriptor, substitutedReceiverType, extensionReceiverParameter.getValue()), + extensionReceiverParameter.getAnnotations() + ); } else { - substitutedReceiverType = null; + substitutedExtensionReceiver = null; } - substitutedDescriptor.setType(outType, substitutedTypeParameters, substitutedDispatchReceiver, substitutedReceiverType); + substitutedDescriptor.setType(outType, substitutedTypeParameters, substitutedDispatchReceiver, substitutedExtensionReceiver); PropertyGetterDescriptorImpl newGetter = getter == null ? null : new PropertyGetterDescriptorImpl( substitutedDescriptor, getter.getAnnotations(), copyConfiguration.modality, normalizeVisibility(getter.getVisibility(), copyConfiguration.kind), diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 5fe3e503d33..90f3fd1ca32 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -431,11 +431,7 @@ public class ErrorUtils { SourceElement.NO_SOURCE, false, false, false, false, false, false ); - descriptor.setType(ERROR_PROPERTY_TYPE, - Collections.emptyList(), - null, - (KotlinType) null - ); + descriptor.setType(ERROR_PROPERTY_TYPE, Collections.emptyList(), null, null); return descriptor; } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 66dae826ec2..48599a7c937 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -63,7 +63,9 @@ class MemberDeserializer(private val c: DeserializationContext) { local.typeDeserializer.type(proto.returnType(c.typeTable)), local.typeDeserializer.ownTypeParameters, getDispatchReceiverParameter(), - proto.receiverType(c.typeTable)?.let { local.typeDeserializer.type(it, receiverAnnotations) } + proto.receiverType(c.typeTable)?.let { local.typeDeserializer.type(it, receiverAnnotations) }?.let { receiverType -> + DescriptorFactory.createExtensionReceiverParameterForCallable(property, receiverType, Annotations.EMPTY) + } ) val getter = if (hasGetter) { diff --git a/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/res/syntheticDescriptorGeneration.kt b/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/res/syntheticDescriptorGeneration.kt index 8b75323d320..f81940f958f 100644 --- a/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/res/syntheticDescriptorGeneration.kt +++ b/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/res/syntheticDescriptorGeneration.kt @@ -123,7 +123,8 @@ private fun genProperty( flexibleType, emptyList(), null, - receiverType) + DescriptorFactory.createExtensionReceiverParameterForCallable(property, receiverType, Annotations.EMPTY) + ) val getter = PropertyGetterDescriptorImpl( property,