[FE] Determine intersection type emptiness by looking at supertypes properly: substitute their type arguments

This commit is contained in:
Victor Petukhov
2022-04-26 20:13:56 +03:00
committed by teamcity
parent a0260292ec
commit 20a8e5d742
17 changed files with 315 additions and 17 deletions
@@ -30,8 +30,7 @@ import org.jetbrains.kotlin.utils.sure
import java.util.*
class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor) : MemberScope {
private val substitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor()
val substitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor()
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor>? = null
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
import org.jetbrains.kotlin.resolve.descriptorUtil.*
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope
import org.jetbrains.kotlin.resolve.substitutedUnderlyingType
import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
import org.jetbrains.kotlin.types.*
@@ -870,6 +871,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
return getKFunctionDescriptor(builtIns, parametersNumber, isSuspend).typeConstructor
}
override fun createSubstitutorForSuperTypes(baseType: KotlinTypeMarker): TypeSubstitutorMarker? {
require(baseType is KotlinType, baseType::errorMessage)
return (baseType.memberScope as? SubstitutingScope)?.substitutor
}
override fun SimpleTypeMarker.createConstraintPartForLowerBoundAndFlexibleTypeVariable(): KotlinTypeMarker =
if (this.isMarkedNullable()) {
this