Data flow values refactoring: removed DataFlowValue.kind.isStable, renamed DataFlowValue.isPredictable -> DataFlowValue.isStable
This commit is contained in:
+2
-2
@@ -186,7 +186,7 @@ class ReferenceVariantsHelper(
|
||||
listOf(useReceiverType)
|
||||
}
|
||||
else {
|
||||
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, predictableSmartCastsOnly = false)!!
|
||||
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, stableSmartCastsOnly = false)!!
|
||||
}
|
||||
|
||||
descriptors.processAll(implicitReceiverTypes, explicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter)
|
||||
@@ -244,7 +244,7 @@ class ReferenceVariantsHelper(
|
||||
listOf(useReceiverType)
|
||||
}
|
||||
else {
|
||||
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, predictableSmartCastsOnly = false)!!
|
||||
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, stableSmartCastsOnly = false)!!
|
||||
}
|
||||
|
||||
val constructorFilter = { descriptor: ClassDescriptor -> if (isStatic) true else descriptor.isInner }
|
||||
|
||||
@@ -213,7 +213,7 @@ fun CallTypeAndReceiver<*, *>.receiverTypes(
|
||||
contextElement: PsiElement,
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
resolutionFacade: ResolutionFacade,
|
||||
predictableSmartCastsOnly: Boolean
|
||||
stableSmartCastsOnly: Boolean
|
||||
): Collection<KotlinType>? {
|
||||
val receiverExpression: KtExpression?
|
||||
when (this) {
|
||||
@@ -225,7 +225,7 @@ fun CallTypeAndReceiver<*, *>.receiverTypes(
|
||||
|
||||
is DoubleColonLHS.Expression -> {
|
||||
val receiverValue = ExpressionReceiver.create(receiver, lhs.type, bindingContext)
|
||||
return receiverValueTypes(receiverValue, lhs.dataFlowInfo, bindingContext, moduleDescriptor, predictableSmartCastsOnly)
|
||||
return receiverValueTypes(receiverValue, lhs.dataFlowInfo, bindingContext, moduleDescriptor, stableSmartCastsOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ fun CallTypeAndReceiver<*, *>.receiverTypes(
|
||||
val dataFlowInfo = bindingContext.getDataFlowInfo(contextElement)
|
||||
|
||||
return receiverValues.flatMap {
|
||||
receiverValueTypes(it, dataFlowInfo, bindingContext, moduleDescriptor, predictableSmartCastsOnly)
|
||||
receiverValueTypes(it, dataFlowInfo, bindingContext, moduleDescriptor, stableSmartCastsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,10 +290,10 @@ private fun receiverValueTypes(
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
bindingContext: BindingContext,
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
predictableSmartCastsOnly: Boolean
|
||||
stableSmartCastsOnly: Boolean
|
||||
): List<KotlinType> {
|
||||
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverValue, bindingContext, moduleDescriptor)
|
||||
return if (dataFlowValue.isPredictable || !predictableSmartCastsOnly) { // we don't include smart cast receiver types for "unpredictable" receiver value to mark members grayed
|
||||
return if (dataFlowValue.isStable || !stableSmartCastsOnly) { // we don't include smart cast receiver types for "unstable" receiver value to mark members grayed
|
||||
SmartCastManager().getSmartCastVariantsWithLessSpecificExcluded(receiverValue, bindingContext, moduleDescriptor, dataFlowInfo)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -439,7 +439,7 @@ abstract class CompletionSession(
|
||||
|
||||
var receiverTypes = callTypeAndReceiver.receiverTypes(
|
||||
bindingContext, nameExpression, moduleDescriptor, resolutionFacade,
|
||||
predictableSmartCastsOnly = true /* we don't include smart cast receiver types for "unpredictable" receiver value to mark members grayed */)
|
||||
stableSmartCastsOnly = true /* we don't include smart cast receiver types for "unstable" receiver value to mark members grayed */)
|
||||
|
||||
if (callTypeAndReceiver is CallTypeAndReceiver.SAFE || isDebuggerContext) {
|
||||
receiverTypes = receiverTypes?.map { it.makeNotNullable() }
|
||||
|
||||
@@ -132,7 +132,7 @@ class KotlinIndicesHelper(
|
||||
bindingContext: BindingContext,
|
||||
nameFilter: (String) -> Boolean
|
||||
): Collection<CallableDescriptor> {
|
||||
val receiverTypes = callTypeAndReceiver.receiverTypes(bindingContext, position, moduleDescriptor, resolutionFacade, predictableSmartCastsOnly = false)
|
||||
val receiverTypes = callTypeAndReceiver.receiverTypes(bindingContext, position, moduleDescriptor, resolutionFacade, stableSmartCastsOnly = false)
|
||||
?: return emptyList()
|
||||
return getCallableTopLevelExtensions(callTypeAndReceiver, receiverTypes, nameFilter)
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class SurroundWithNullCheckFix(
|
||||
else -> return null
|
||||
} as? KtReferenceExpression ?: return null
|
||||
|
||||
if (!nullableExpression.isPredictable()) return null
|
||||
if (!nullableExpression.isStable()) return null
|
||||
|
||||
return SurroundWithNullCheckFix(expression, nullableExpression)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class SurroundWithNullCheckFix(
|
||||
val forExpression = nullableExpression.parent?.parent as? KtForExpression ?: return null
|
||||
if (forExpression.parent !is KtBlockExpression) return null
|
||||
|
||||
if (!nullableExpression.isPredictable()) return null
|
||||
if (!nullableExpression.isStable()) return null
|
||||
|
||||
return SurroundWithNullCheckFix(forExpression, nullableExpression)
|
||||
}
|
||||
@@ -97,16 +97,16 @@ class SurroundWithNullCheckFix(
|
||||
|
||||
if (!isNullabilityMismatch(expected = typeMismatch.a, actual = typeMismatch.b)) return null
|
||||
|
||||
if (!nullableExpression.isPredictable()) return null
|
||||
if (!nullableExpression.isStable()) return null
|
||||
|
||||
return SurroundWithNullCheckFix(call, nullableExpression)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtExpression.isPredictable(): Boolean {
|
||||
private fun KtExpression.isStable(): Boolean {
|
||||
val context = this.analyze()
|
||||
val nullableType = this.getType(context) ?: return false
|
||||
val containingDescriptor = this.getResolutionScope(context, this.getResolutionFacade()).ownerDescriptor
|
||||
return DataFlowValueFactory.createDataFlowValue(this, nullableType, context, containingDescriptor).isPredictable
|
||||
return DataFlowValueFactory.createDataFlowValue(this, nullableType, context, containingDescriptor).isStable
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class AbstractDataFlowValueRenderingTest: KotlinLightCodeInsightFixture
|
||||
|
||||
private fun DataFlowValue.render() =
|
||||
// If it is not a stable identifier, there's no point in rendering it
|
||||
if (!isPredictable) null
|
||||
if (!isStable) null
|
||||
else identifierInfo.render()
|
||||
|
||||
override fun getTestDataPath() : String {
|
||||
|
||||
Reference in New Issue
Block a user