[JVM] Validate lowered JVM IR only if it was explicitly requested

This is an addition to the f5bb477459
commit. Earlier, some of the validation checks were moved from
`stickyPostconditions` into separate lowering. But these
post-conditions checks were launched only when several flags were
set to true. In this commit, we just return to such behavior.

#KT-64116
This commit is contained in:
Ivan Kylchik
2023-12-25 12:08:04 +01:00
committed by Space Team
parent a55c65e3e2
commit 8ed7e31b5f
2 changed files with 4 additions and 2 deletions
@@ -82,7 +82,7 @@ private val validateIrAfterLowering = makeCustomPhase(
)
private val validateJvmIrAfterLowering = makeCustomPhase<JvmBackendContext>(
{ _, module -> validateJvmIr(module) },
{ context, module -> validateJvmIr(context, module) },
name = "ValidateJvmIrAfterLowering",
description = "Validate that IR after lowering is correctly structured by Kotlin JVM rules"
)
@@ -27,7 +27,9 @@ private fun checkAllFileLevelDeclarationsAreClasses(module: IrModuleFragment) {
})
}
fun validateJvmIr(module: IrModuleFragment) {
fun validateJvmIr(context: JvmBackendContext, module: IrModuleFragment) {
if (!context.config.shouldValidateIr) return
checkAllFileLevelDeclarationsAreClasses(module)
val validator = object : IrElementVisitorVoid {
override fun visitElement(element: IrElement) {