FIR IDE: introduce KtFirDefinitelyNotNullType

This commit is contained in:
Ilya Kirillov
2021-06-11 13:17:40 +02:00
committed by TeamCityServer
parent 8177a70ff9
commit 73bb2e76f2
3 changed files with 20 additions and 1 deletions
@@ -57,6 +57,12 @@ abstract class KtTypeParameterType : KtTypeWithNullability {
abstract class KtCapturedType : KtType
abstract class KtDefinitelyNotNullType : KtType, KtTypeWithNullability {
abstract val original: KtType
final override val nullability: KtTypeNullability get() = KtTypeNullability.NON_NULLABLE
}
abstract class KtFlexibleType : KtType {
abstract val lowerBound: KtType
abstract val upperBound: KtType
@@ -319,7 +319,7 @@ internal class KtSymbolByFirBuilder private constructor(
is ConeClassErrorType -> KtFirClassErrorType(coneType, token)
is ConeFlexibleType -> KtFirFlexibleType(coneType, token, this@KtSymbolByFirBuilder)
is ConeIntersectionType -> KtFirIntersectionType(coneType, token, this@KtSymbolByFirBuilder)
is ConeDefinitelyNotNullType -> buildKtType(coneType.original)
is ConeDefinitelyNotNullType -> KtFirDefinitelyNotNullType(coneType, token, this@KtSymbolByFirBuilder)
is ConeCapturedType -> KtFirCapturedType(coneType, token)
else -> throwUnexpectedElementError(coneType)
}
@@ -109,6 +109,19 @@ internal class KtFirCapturedType(
override fun asStringForDebugging(): String = withValidityAssertion { coneType.render() }
}
internal class KtFirDefinitelyNotNullType(
coneType: ConeDefinitelyNotNullType,
override val token: ValidityToken,
private val firBuilder: KtSymbolByFirBuilder,
) : KtDefinitelyNotNullType(), KtFirType {
override val coneType by weakRef(coneType)
override val original: KtType by cached { firBuilder.typeBuilder.buildKtType(this.coneType.original) }
override fun asStringForDebugging(): String = withValidityAssertion { coneType.render() }
}
internal class KtFirTypeParameterType(
coneType: ConeTypeParameterType,