Fixes for IDE tests after qualifier modifications:
- CallType should look into QUALIFIER, so that completion works for (companion) object qualifiers. - Record type and reference target for object qualifiers (not only for companions). - "Create (function/...)" should understand ClassQualifier as possible receiver. - Cleanup after rebase on master.
This commit is contained in:
@@ -28,9 +28,11 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.companionObjectType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassQualifier
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.supertypesWithAny
|
||||
@@ -247,8 +249,13 @@ public fun CallTypeAndReceiver<*, *>.receiverTypes(
|
||||
}
|
||||
|
||||
val receiverValues = if (receiverExpression != null) {
|
||||
val expressionType = bindingContext.getType(receiverExpression)
|
||||
expressionType?.let { listOf(ExpressionReceiver.create(receiverExpression, expressionType, bindingContext)) } ?: return emptyList()
|
||||
val receiverType =
|
||||
bindingContext.getType(receiverExpression) ?:
|
||||
(bindingContext.get(BindingContext.QUALIFIER, receiverExpression) as? ClassQualifier)?.let {
|
||||
it.classifier.companionObjectType
|
||||
} ?:
|
||||
return emptyList()
|
||||
listOf(ExpressionReceiver.create(receiverExpression, receiverType, bindingContext))
|
||||
}
|
||||
else {
|
||||
val resolutionScope = contextElement.getResolutionScope(bindingContext, resolutionFacade)
|
||||
|
||||
+8
-3
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.companionObjectType
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassQualifier
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||
@@ -111,11 +112,15 @@ sealed class CreateCallableFromCallActionFactory<E : KtExpression>(
|
||||
receiver is Qualifier -> {
|
||||
val qualifierType = context.getType(receiver.expression)
|
||||
if (qualifierType != null) return TypeInfo(qualifierType, Variance.IN_VARIANCE)
|
||||
|
||||
if (receiver !is ClassQualifier) return null
|
||||
val classifier = receiver.classifier as? JavaClassDescriptor ?: return null
|
||||
val javaClass = DescriptorToSourceUtilsIde.getAnyDeclaration(project, classifier) as? PsiClass
|
||||
val classifierType = receiver.classifier.companionObjectType
|
||||
if (classifierType != null) return TypeInfo(classifierType, Variance.IN_VARIANCE)
|
||||
|
||||
val javaClassifier = receiver.classifier as? JavaClassDescriptor ?: return null
|
||||
val javaClass = DescriptorToSourceUtilsIde.getAnyDeclaration(project, javaClassifier) as? PsiClass
|
||||
if (javaClass == null || !javaClass.canRefactor()) return null
|
||||
TypeInfo.StaticContextRequired(TypeInfo(classifier.defaultType, Variance.IN_VARIANCE))
|
||||
TypeInfo.StaticContextRequired(TypeInfo(javaClassifier.defaultType, Variance.IN_VARIANCE))
|
||||
}
|
||||
receiver is ReceiverValue -> TypeInfo(receiver.type, Variance.IN_VARIANCE)
|
||||
else -> throw AssertionError("Unexpected receiver: $receiver")
|
||||
|
||||
Reference in New Issue
Block a user