[FIR] Assert source is not-null when reporting cone diagnostics

#KT-55835
#KT-59856
This commit is contained in:
Kirill Rakhman
2023-07-18 10:23:30 +02:00
committed by Space Team
parent 2f3293f99e
commit 9288a96f6d
10 changed files with 70 additions and 72 deletions
@@ -15,7 +15,7 @@ fun DiagnosticReporter.reportOn(
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(requireSourceNotNull(source), positioningStrategy), context)
report(factory.on(source.requireNotNull(), positioningStrategy), context)
}
fun <A : Any> DiagnosticReporter.reportOn(
@@ -25,7 +25,7 @@ fun <A : Any> DiagnosticReporter.reportOn(
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(requireSourceNotNull(source), a, positioningStrategy), context)
report(factory.on(source.requireNotNull(), a, positioningStrategy), context)
}
fun <A : Any, B : Any> DiagnosticReporter.reportOn(
@@ -36,7 +36,7 @@ fun <A : Any, B : Any> DiagnosticReporter.reportOn(
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(requireSourceNotNull(source), a, b, positioningStrategy), context)
report(factory.on(source.requireNotNull(), a, b, positioningStrategy), context)
}
fun <A : Any, B : Any, C : Any> DiagnosticReporter.reportOn(
@@ -48,7 +48,7 @@ fun <A : Any, B : Any, C : Any> DiagnosticReporter.reportOn(
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(requireSourceNotNull(source), a, b, c, positioningStrategy), context)
report(factory.on(source.requireNotNull(), a, b, c, positioningStrategy), context)
}
fun <A : Any, B : Any, C : Any, D : Any> DiagnosticReporter.reportOn(
@@ -61,11 +61,11 @@ fun <A : Any, B : Any, C : Any, D : Any> DiagnosticReporter.reportOn(
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(requireSourceNotNull(source), a, b, c, d, positioningStrategy), context)
report(factory.on(source.requireNotNull(), a, b, c, d, positioningStrategy), context)
}
private fun requireSourceNotNull(source: AbstractKtSourceElement?): AbstractKtSourceElement =
requireNotNull(source) { "source must not be null" }
fun AbstractKtSourceElement?.requireNotNull(): AbstractKtSourceElement =
requireNotNull(this) { "source must not be null" }
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,