[FIR] Add temporary debug output to better understand CME on TeamCity

This commit should be reverted as soon as the reason for those
exceptions is found and fixed.

Tracking issue is KTIJ-21791
This commit is contained in:
Roman Golyshev
2022-05-19 14:13:47 +04:00
committed by teamcity
parent d7bfa02bb3
commit 934b8c890e
2 changed files with 46 additions and 2 deletions
@@ -7,7 +7,10 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.util
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.utils.classId
import org.jetbrains.kotlin.fir.psi
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
import org.jetbrains.kotlin.psi.KtElement
@@ -33,6 +36,28 @@ object FirElementFinder {
}
}
}
override fun visitRegularClass(regularClass: FirRegularClass) {
// Checking the rest super types that weren't resolved on the first OUTER_CLASS_ARGUMENTS_REQUIRED check in FirTypeResolver
val oldResolvePhase = regularClass.resolvePhase
val oldList = regularClass.superTypeRefs.toList()
try {
super.visitRegularClass(regularClass)
} catch (e: ConcurrentModificationException) {
val newResolvePhase = regularClass.resolvePhase
val newList = regularClass.superTypeRefs.toList()
throw IllegalStateException(
"""
CME while traversing superTypeRefs of declaration=${regularClass.render()}:
classId: ${regularClass.classId},
oldPhase: $oldResolvePhase, oldList: ${oldList.joinToString(",", "[", "]") { it.render() }},
newPhase: $newResolvePhase, newList: ${newList.joinToString(",", "[", "]") { it.render() }}
""".trimIndent(), e
)
}
}
})
return result
}