[FIR] Add REDUNDANT_NULLABLE diagnostics

This commit is contained in:
Ivan Kochurkin
2021-11-19 16:21:51 +03:00
committed by TeamCityServer
parent 4caf3c5e83
commit 51b73bb6ae
37 changed files with 233 additions and 87 deletions
@@ -62,20 +62,20 @@ fun FirExpression.isStableSmartcast(): Boolean {
return this is FirExpressionWithSmartcast && this.isStable
}
private val FirTypeRef.classLikeTypeOrNull: ConeClassLikeType?
private val FirTypeRef.lookupTagBasedOrNull: ConeLookupTagBasedType?
get() = when (this) {
is FirImplicitBuiltinTypeRef -> type
is FirResolvedTypeRef -> type as? ConeClassLikeType
is FirResolvedTypeRef -> type as? ConeLookupTagBasedType
else -> null
}
private fun FirTypeRef.isBuiltinType(classId: ClassId, isNullable: Boolean): Boolean {
val type = this.classLikeTypeOrNull ?: return false
return type.lookupTag.classId == classId && type.isNullable == isNullable
val type = this.lookupTagBasedOrNull ?: return false
return (type as? ConeClassLikeType)?.lookupTag?.classId == classId && type.isNullable == isNullable
}
val FirTypeRef.isMarkedNullable: Boolean?
get() = classLikeTypeOrNull?.isMarkedNullable
get() = if (this is FirTypeRefWithNullability) this.isMarkedNullable else lookupTagBasedOrNull?.isMarkedNullable
val FirFunctionTypeRef.parametersCount: Int
get() = if (receiverTypeRef != null)