Do substitution of stub types inside smartcast types to further write it into trace and prevent dealing with that in the back-end
This commit is contained in:
+5
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.BindingContext.SMARTCAST
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.BuilderInferenceSession
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -136,7 +137,10 @@ class SmartCastManager(private val argumentTypeResolver: ArgumentTypeResolver) {
|
||||
else
|
||||
listOf(expectedType)
|
||||
|
||||
val collectedTypes = c.dataFlowInfo.getCollectedTypes(dataFlowValue, c.languageVersionSettings).toMutableList()
|
||||
val builderInferenceSubstitutor = (c.inferenceSession as? BuilderInferenceSession)?.getNotFixedToInferredTypesSubstitutor()
|
||||
val collectedTypes = c.dataFlowInfo.getCollectedTypes(dataFlowValue, c.languageVersionSettings).let { types ->
|
||||
if (builderInferenceSubstitutor != null) types.map { builderInferenceSubstitutor.safeSubstitute(it.unwrap()) } else types
|
||||
}.toMutableList()
|
||||
|
||||
if (collectedTypes.isNotEmpty() && c.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) {
|
||||
// Sometime expected type may be inferred to be an intersection of all of the smart-cast types
|
||||
|
||||
Reference in New Issue
Block a user