FIR: no nullability in error type

This commit is contained in:
Mikhail Glukhikh
2018-03-20 12:00:52 +03:00
parent 3e7b9c4e27
commit fa80f40e74
3 changed files with 7 additions and 8 deletions
@@ -69,7 +69,7 @@ class RawFirBuilder(val session: FirSession) {
convertSafe() ?: FirImplicitTypeImpl(session, this) convertSafe() ?: FirImplicitTypeImpl(session, this)
private fun KtTypeReference?.toFirOrErrorType(): FirType = private fun KtTypeReference?.toFirOrErrorType(): FirType =
convertSafe() ?: FirErrorTypeImpl(session, this, false, if (this == null) "Incomplete code" else "Conversion failed") convertSafe() ?: FirErrorTypeImpl(session, this, if (this == null) "Incomplete code" else "Conversion failed")
private fun KtExpression?.toFirBody(): FirBody? = private fun KtExpression?.toFirBody(): FirBody? =
convertSafe<FirExpression>()?.let { it as? FirBody ?: FirExpressionBodyImpl(session, it) } convertSafe<FirExpression>()?.let { it as? FirBody ?: FirExpressionBodyImpl(session, it) }
@@ -178,7 +178,7 @@ class RawFirBuilder(val session: FirSession) {
FirDelegatedConstructorCallImpl( FirDelegatedConstructorCallImpl(
session, session,
constructorCallee, constructorCallee,
FirErrorTypeImpl(session, constructorCallee, false, "Not implemented yet"), FirErrorTypeImpl(session, constructorCallee, "Not implemented yet"),
isThis = false isThis = false
).apply { ).apply {
superTypeCallEntry.extractArgumentsTo(this) superTypeCallEntry.extractArgumentsTo(this)
@@ -317,7 +317,7 @@ class RawFirBuilder(val session: FirSession) {
val firConstructorCall = FirDelegatedConstructorCallImpl( val firConstructorCall = FirDelegatedConstructorCallImpl(
session, session,
call, call,
FirErrorTypeImpl(session, call, false, "Not implemented yet"), FirErrorTypeImpl(session, call, "Not implemented yet"),
call.isCallToThis || call.isImplicit call.isCallToThis || call.isImplicit
) )
call.extractArgumentsTo(firConstructorCall) call.extractArgumentsTo(firConstructorCall)
@@ -384,7 +384,7 @@ class RawFirBuilder(val session: FirSession) {
} while (referenceExpression != null) } while (referenceExpression != null)
userType userType
} else { } else {
FirErrorTypeImpl(session, typeReference, isNullable, "Incomplete user type") FirErrorTypeImpl(session, typeReference, "Incomplete user type")
} }
} }
is KtFunctionType -> { is KtFunctionType -> {
@@ -400,7 +400,7 @@ class RawFirBuilder(val session: FirSession) {
} }
functionType functionType
} }
null -> FirErrorTypeImpl(session, typeReference, isNullable, "Unwrapped type is null") null -> FirErrorTypeImpl(session, typeReference, "Unwrapped type is null")
else -> throw AssertionError("Unexpected type element: ${unwrappedElement.text}") else -> throw AssertionError("Unexpected type element: ${unwrappedElement.text}")
} }
@@ -333,7 +333,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
override fun visitErrorType(errorType: FirErrorType) { override fun visitErrorType(errorType: FirErrorType) {
visitType(errorType) visitType(errorType)
print("<ERROR TYPE>") print("<ERROR TYPE: ${errorType.reason}>")
} }
override fun visitImplicitType(implicitType: FirImplicitType) { override fun visitImplicitType(implicitType: FirImplicitType) {
@@ -13,9 +13,8 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor
class FirErrorTypeImpl( class FirErrorTypeImpl(
session: FirSession, session: FirSession,
psi: PsiElement?, psi: PsiElement?,
isNullable: Boolean,
override val reason: String override val reason: String
) : FirAbstractAnnotatedType(session, psi, isNullable), FirErrorType { ) : FirAbstractAnnotatedType(session, psi, false), FirErrorType {
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R { override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R {
return super<FirErrorType>.accept(visitor, data) return super<FirErrorType>.accept(visitor, data)
} }