[FIR] Introduce unchecked not-null cast as internal operation for !!, ?:

This commit is contained in:
Simon Ogorodnik
2019-05-15 15:48:26 +03:00
committed by Mikhail Glukhikh
parent b469eb293b
commit aa96837758
16 changed files with 138 additions and 43 deletions
@@ -131,6 +131,17 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
}
}
override fun transformUncheckedNotNullCast(
uncheckedNotNullCast: FirUncheckedNotNullCast,
data: Any?
): CompositeTransformResult<FirStatement> {
val notNullCast = super.transformUncheckedNotNullCast(uncheckedNotNullCast, data).single as FirUncheckedNotNullCast
val resultType = notNullCast.expression.resultType
notNullCast.resultType =
resultType.withReplacedConeType(session, resultType.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NOT_NULL))
return notNullCast.compose()
}
override fun transformTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: Any?): CompositeTransformResult<FirStatement> {
val symbolProvider = session.service<FirSymbolProvider>()
val resolved = super.transformTypeOperatorCall(typeOperatorCall, data).single
@@ -12,7 +12,7 @@ FILE: factoryFunctionOverloads.kt
throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|()
}
else -> {
R|<local>/<bangbang>|
R|<local>/<bangbang>|!
}
}
, R|<local>/flag|)