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:
+7
-1
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
+1
-1
@@ -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(
|
||||
|
||||
+10
-16
@@ -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<? extends TypeParameterDescriptor> 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<? extends TypeParameterDescriptor> 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),
|
||||
|
||||
@@ -431,11 +431,7 @@ public class ErrorUtils {
|
||||
SourceElement.NO_SOURCE,
|
||||
false, false, false, false, false, false
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
null,
|
||||
(KotlinType) null
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE, Collections.<TypeParameterDescriptor>emptyList(), null, null);
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
+3
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user