[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
@@ -120,7 +120,8 @@ private inline fun Any?.errorMessage(): String {
fun NewConstraintSystemImpl(
constraintInjector: ConstraintInjector,
builtIns: KotlinBuiltIns,
kotlinTypeRefiner: KotlinTypeRefiner
kotlinTypeRefiner: KotlinTypeRefiner,
languageVersionSettings: LanguageVersionSettings
): NewConstraintSystemImpl {
return NewConstraintSystemImpl(constraintInjector, ClassicTypeSystemContextForCS(builtIns, kotlinTypeRefiner))
return NewConstraintSystemImpl(constraintInjector, ClassicTypeSystemContextForCS(builtIns, kotlinTypeRefiner), languageVersionSettings)
}
@@ -79,7 +79,8 @@ sealed class ResolutionCandidate : Candidate, KotlinDiagnosticsHolder {
fun getSystem(): NewConstraintSystem {
if (newSystem == null) {
newSystem = NewConstraintSystemImpl(
callComponents.constraintInjector, callComponents.builtIns, callComponents.kotlinTypeRefiner
callComponents.constraintInjector, callComponents.builtIns,
callComponents.kotlinTypeRefiner, callComponents.languageVersionSettings
)
if (baseSystem != null) {
newSystem!!.addOtherSystem(baseSystem!!)
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.resolve.calls.inference.components
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
@@ -33,9 +34,12 @@ import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
class SimpleConstraintSystemImpl(
constraintInjector: ConstraintInjector,
builtIns: KotlinBuiltIns,
kotlinTypeRefiner: KotlinTypeRefiner
kotlinTypeRefiner: KotlinTypeRefiner,
languageVersionSettings: LanguageVersionSettings
) : SimpleConstraintSystem {
val system = NewConstraintSystemImpl(constraintInjector, ClassicTypeSystemContextForCS(builtIns, kotlinTypeRefiner))
val system = NewConstraintSystemImpl(
constraintInjector, ClassicTypeSystemContextForCS(builtIns, kotlinTypeRefiner), languageVersionSettings
)
val csBuilder: ConstraintSystemBuilder =
system.getBuilder()
@@ -33,7 +33,10 @@ class SimpleCandidateFactory(
val baseSystem: ConstraintStorage
init {
val baseSystem = NewConstraintSystemImpl(callComponents.constraintInjector, callComponents.builtIns, callComponents.kotlinTypeRefiner)
val baseSystem = NewConstraintSystemImpl(
callComponents.constraintInjector, callComponents.builtIns,
callComponents.kotlinTypeRefiner, callComponents.languageVersionSettings
)
if (!inferenceSession.resolveReceiverIndependently()) {
baseSystem.addSubsystemFromArgument(kotlinCall.explicitReceiver)
baseSystem.addSubsystemFromArgument(kotlinCall.dispatchReceiverForInvokeExtension)