[NI] Remove unneeded computation of possible types for return type

This call was needed at some point for smartcasts on qualified
 expressions but become obsolete (most likely after
 daa27016ca).

 Now `ComplexDataFlowBenchmark` has similar results for NI and OI
This commit is contained in:
Mikhail Zarechenskiy
2019-09-17 15:43:59 +03:00
parent d47fc85868
commit 0431c21f9a
3 changed files with 4 additions and 30 deletions
@@ -226,21 +226,6 @@ class KotlinResolutionCallbacksImpl(
)
}
override fun createReceiverWithSmartCastInfo(resolvedAtom: ResolvedCallAtom): ReceiverValueWithSmartCastInfo? {
val returnType = resolvedAtom.candidateDescriptor.returnType ?: return null
val psiKotlinCall = resolvedAtom.atom.psiKotlinCall
val callElement = psiKotlinCall.psiCall.callElement.safeAs<KtExpression>() ?: return null
val expression = findCommonParent(callElement, resolvedAtom.atom.psiKotlinCall.explicitReceiver)
return transformToReceiverWithSmartCastInfo(
resolvedAtom.candidateDescriptor,
trace.bindingContext,
psiKotlinCall.resultDataFlowInfo,
ExpressionReceiver.create(expression, returnType, trace.bindingContext),
languageVersionSettings, dataFlowValueFactory
)
}
override fun isCompileTimeConstant(resolvedAtom: ResolvedCallAtom, expectedType: UnwrappedType): Boolean {
val descriptor = resolvedAtom.candidateDescriptor
@@ -56,8 +56,6 @@ interface KotlinResolutionCallbacks {
fun bindStubResolvedCallForCandidate(candidate: ResolvedCallAtom)
fun createReceiverWithSmartCastInfo(resolvedAtom: ResolvedCallAtom): ReceiverValueWithSmartCastInfo?
fun isCompileTimeConstant(resolvedAtom: ResolvedCallAtom, expectedType: UnwrappedType): Boolean
val inferenceSession: InferenceSession
@@ -41,7 +41,7 @@ class KotlinCallCompleter(
}
val candidate = prepareCandidateForCompletion(factory, candidates, resolutionCallbacks)
val returnType = candidate.returnTypeWithSmartCastInfo(resolutionCallbacks)
val returnType = candidate.substitutedReturnType()
candidate.addExpectedTypeConstraint(returnType, expectedType)
candidate.addExpectedTypeFromCastConstraint(returnType, resolutionCallbacks)
@@ -65,7 +65,7 @@ class KotlinCallCompleter(
val diagnosticsHolder = KotlinDiagnosticsHolder.SimpleHolder()
candidate.addExpectedTypeConstraint(
candidate.returnTypeWithSmartCastInfo(resolutionCallbacks), expectedType
candidate.substitutedReturnType(), expectedType
)
runCompletion(
@@ -143,10 +143,9 @@ class KotlinCallCompleter(
return candidate ?: factory.createErrorCandidate().forceResolution()
}
private fun KotlinResolutionCandidate.returnTypeWithSmartCastInfo(resolutionCallbacks: KotlinResolutionCallbacks): UnwrappedType? {
private fun KotlinResolutionCandidate.substitutedReturnType(): UnwrappedType? {
val returnType = resolvedCall.candidateDescriptor.returnType?.unwrap() ?: return null
val returnTypeWithSmartCastInfo = computeReturnTypeWithSmartCastInfo(returnType, resolutionCallbacks)
return resolvedCall.substitutor.safeSubstitute(returnTypeWithSmartCastInfo)
return resolvedCall.substitutor.safeSubstitute(returnType)
}
private fun KotlinResolutionCandidate.addExpectedTypeConstraint(
@@ -250,14 +249,6 @@ class KotlinCallCompleter(
private inline fun <T> Iterable<T>.anyOrAll(requireAll: Boolean, p: (T) -> Boolean): Boolean =
if (requireAll) all(p) else any(p)
private fun KotlinResolutionCandidate.computeReturnTypeWithSmartCastInfo(
returnType: UnwrappedType,
resolutionCallbacks: KotlinResolutionCallbacks
): UnwrappedType {
if (resolvedCall.atom.callKind != KotlinCallKind.VARIABLE) return returnType
return resolutionCallbacks.createReceiverWithSmartCastInfo(resolvedCall)?.stableType ?: returnType
}
fun KotlinResolutionCandidate.asCallResolutionResult(
type: ConstraintSystemCompletionMode,
diagnosticsHolder: KotlinDiagnosticsHolder.SimpleHolder