FIR: Convert couple of methods to block-body

This commit is contained in:
Denis.Zharkov
2021-05-19 18:21:00 +03:00
committed by teamcityserver
parent 7c05c6420a
commit 36c9418d55
@@ -163,11 +163,12 @@ private fun mapSystemHasContradictionError(
diagnostic: ConeConstraintSystemHasContradiction, diagnostic: ConeConstraintSystemHasContradiction,
source: FirSourceElement, source: FirSourceElement,
qualifiedAccessSource: FirSourceElement?, qualifiedAccessSource: FirSourceElement?,
): List<FirDiagnostic<FirSourceElement>> = buildList<FirDiagnostic<FirSourceElement>> { ): List<FirDiagnostic<FirSourceElement>> {
return buildList<FirDiagnostic<FirSourceElement>> {
for (error in diagnostic.candidate.system.errors) { for (error in diagnostic.candidate.system.errors) {
addIfNotNull(error.toDiagnostic(source, qualifiedAccessSource, diagnostic.candidate.callInfo.session.typeContext)) addIfNotNull(error.toDiagnostic(source, qualifiedAccessSource, diagnostic.candidate.callInfo.session.typeContext))
} }
}.ifEmpty { }.ifEmpty {
listOfNotNull( listOfNotNull(
diagnostic.candidate.system.errors.firstNotNullOfOrNull { diagnostic.candidate.system.errors.firstNotNullOfOrNull {
val message = when (it) { val message = when (it) {
@@ -179,13 +180,15 @@ private fun mapSystemHasContradictionError(
FirErrors.NEW_INFERENCE_ERROR.on(qualifiedAccessSource ?: source, message) FirErrors.NEW_INFERENCE_ERROR.on(qualifiedAccessSource ?: source, message)
} }
) )
}
} }
private fun ConstraintSystemError.toDiagnostic( private fun ConstraintSystemError.toDiagnostic(
source: FirSourceElement, source: FirSourceElement,
qualifiedAccessSource: FirSourceElement?, qualifiedAccessSource: FirSourceElement?,
typeContext: ConeTypeContext, typeContext: ConeTypeContext,
): FirDiagnostic<FirSourceElement>? = when (this) { ): FirDiagnostic<FirSourceElement>? {
return when (this) {
is NewConstraintError -> { is NewConstraintError -> {
val position = position.from val position = position.from
val argument = val argument =
@@ -223,6 +226,7 @@ private fun ConstraintSystemError.toDiagnostic(
} }
} }
else -> null else -> null
}
} }
private val NewConstraintError.lowerConeType: ConeKotlinType get() = lowerType as ConeKotlinType private val NewConstraintError.lowerConeType: ConeKotlinType get() = lowerType as ConeKotlinType