[FE 1.0] Use the new type intersection emptiness check

Also introduced compatibility mode to preserve compatibility for is/as/equality checks

^KT-29316 Related
This commit is contained in:
Victor Petukhov
2022-06-09 09:59:55 +02:00
committed by teamcity
parent bc1c2adae1
commit 8227c4b603
15 changed files with 90 additions and 24 deletions
@@ -48,8 +48,6 @@ interface KotlinResolutionStatelessCallbacks {
fun isBuilderInferenceCall(argument: KotlinCallArgument, parameter: ValueParameterDescriptor): Boolean
fun isApplicableCallForBuilderInference(descriptor: CallableDescriptor, languageVersionSettings: LanguageVersionSettings): Boolean
fun isOldIntersectionIsEmpty(types: Collection<KotlinType>): Boolean
fun createConstraintSystemForOverloadResolution(
constraintInjector: ConstraintInjector, builtIns: KotlinBuiltIns
): SimpleConstraintSystem
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.types.error.ErrorUtils
import org.jetbrains.kotlin.types.model.*
import org.jetbrains.kotlin.types.typeUtil.*
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.jetbrains.kotlin.utils.addToStdlib.compactIfPossible
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -885,8 +884,8 @@ internal object CheckIncompatibleTypeVariableUpperBounds : ResolutionPart() {
* Check if the candidate was already discriminated by `CompatibilityOfTypeVariableAsIntersectionTypePart` resolution part
* If it's true we shouldn't mark the candidate with warning, but should mark with error, to repeat the existing proper behaviour
*/
private fun ResolutionCandidate.wasPreviouslyDiscriminated(upperTypes: List<KotlinTypeMarker>) =
callComponents.statelessCallbacks.isOldIntersectionIsEmpty(upperTypes.cast())
private fun wasPreviouslyDiscriminated(upperTypes: List<KotlinTypeMarker>) =
isEmptyIntersectionTypeCompatible(*upperTypes.toTypedArray())
override fun ResolutionCandidate.process(workIndex: Int) = with(getSystem().asConstraintSystemCompleterContext()) {
val constraintSystem = getSystem()