[FE] Check if type variable is fixed into an empty intersection type and report resolution warnings/errors if needed (completion stage)

^KT-51221 Fixed
This commit is contained in:
Victor Petukhov
2022-02-11 11:37:48 +03:00
committed by teamcity
parent 8e834fc7bb
commit 9e9e0211eb
17 changed files with 93 additions and 19 deletions
@@ -61,7 +61,9 @@ class BuilderInferenceSession(
psiCallResolver, postponedArgumentsAnalyzer, kotlinConstraintSystemCompleter, callComponents, builtIns
) {
private lateinit var lambda: ResolvedLambdaAtom
private val commonSystem = NewConstraintSystemImpl(callComponents.constraintInjector, builtIns, callComponents.kotlinTypeRefiner)
private val commonSystem = NewConstraintSystemImpl(
callComponents.constraintInjector, builtIns, callComponents.kotlinTypeRefiner, topLevelCallContext.languageVersionSettings
)
init {
if (topLevelCallContext.inferenceSession is StubTypesBasedInferenceSession<*>) {
@@ -103,8 +103,9 @@ class KotlinResolutionCallbacksImpl(
) as KotlinType
}
override fun createEmptyConstraintSystem(): NewConstraintSystem =
NewConstraintSystemImpl(callComponents.constraintInjector, callComponents.builtIns, callComponents.kotlinTypeRefiner)
override fun createEmptyConstraintSystem(): NewConstraintSystem = NewConstraintSystemImpl(
callComponents.constraintInjector, callComponents.builtIns, callComponents.kotlinTypeRefiner, callComponents.languageVersionSettings
)
override fun resolveCallableReferenceArgument(
argument: CallableReferenceKotlinCallArgument,
@@ -113,7 +113,7 @@ class KotlinResolutionStatelessCallbacksImpl(
constraintInjector: ConstraintInjector, builtIns: KotlinBuiltIns
): SimpleConstraintSystem {
return if (languageVersionSettings.getFlag(AnalysisFlags.constraintSystemForOverloadResolution).forNewInference())
SimpleConstraintSystemImpl(constraintInjector, builtIns, kotlinTypeRefiner)
SimpleConstraintSystemImpl(constraintInjector, builtIns, kotlinTypeRefiner, languageVersionSettings)
else
ConstraintSystemBuilderImpl.forSpecificity()
}
@@ -120,7 +120,9 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
for (callInfo in listOf(goodCandidate, badCandidate)) {
val atomsToAnalyze = mutableListOf<ResolvedAtom>(callInfo.callResolutionResult)
val system = NewConstraintSystemImpl(callComponents.constraintInjector, builtIns, callComponents.kotlinTypeRefiner).apply {
val system = NewConstraintSystemImpl(
callComponents.constraintInjector, builtIns, callComponents.kotlinTypeRefiner, callComponents.languageVersionSettings
).apply {
addOtherSystem(callInfo.callResolutionResult.constraintSystem.getBuilder().currentStorage())
/*
* This is needed for very stupid case, when we have some delegate with good `getValue` and bad `setValue` that
@@ -159,7 +161,8 @@ abstract class StubTypesBasedInferenceSession<D : CallableDescriptor>(
val commonSystem = NewConstraintSystemImpl(
callComponents.constraintInjector,
builtIns,
callComponents.kotlinTypeRefiner
callComponents.kotlinTypeRefiner,
callComponents.languageVersionSettings
).apply {
addOtherSystem(currentConstraintSystem())
}