FIR: revert a hack that allows overriding T!! with T

1. this should've been only done if the language feature for validating
    that is disabled;

 2. that feature probably won't matter by the time FIR is stable;

 3. it only worked because type enhancement of type arguments is broken
    anyway - a more correct hack would be to provide a custom
    ConeTypePreparator.
This commit is contained in:
pyos
2021-08-02 12:20:40 +02:00
committed by teamcityserver
parent c85329905c
commit 5fec9f34b1
8 changed files with 42 additions and 37 deletions
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractOverrideChecker() {
private val context: ConeTypeContext = session.typeContext
private val context = session.typeContext
private fun isEqualTypes(substitutedCandidateType: ConeKotlinType, substitutedBaseType: ConeKotlinType): Boolean {
return with(context) {
@@ -45,16 +45,11 @@ class FirStandardOverrideChecker(private val session: FirSession) : FirAbstractO
}
private fun isEqualTypes(candidateType: ConeKotlinType, baseType: ConeKotlinType, substitutor: ConeSubstitutor): Boolean {
val substitutedCandidateType = substitutor.substituteOrSelf(candidateType).unwrapDefinitelyNotNullType()
val substitutedBaseType = substitutor.substituteOrSelf(baseType).unwrapDefinitelyNotNullType()
val substitutedCandidateType = substitutor.substituteOrSelf(candidateType)
val substitutedBaseType = substitutor.substituteOrSelf(baseType)
return isEqualTypes(substitutedCandidateType, substitutedBaseType)
}
private fun ConeKotlinType.unwrapDefinitelyNotNullType(): ConeKotlinType = when (this) {
is ConeDefinitelyNotNullType -> original
else -> this
}
fun isEqualTypes(candidateTypeRef: FirTypeRef, baseTypeRef: FirTypeRef, substitutor: ConeSubstitutor): Boolean {
candidateTypeRef.ensureResolvedTypeDeclaration(session, requiredPhase = FirResolvePhase.TYPES)
baseTypeRef.ensureResolvedTypeDeclaration(session, requiredPhase = FirResolvePhase.TYPES)