[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
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.extractArgumentsTypeRefAndSource
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
import org.jetbrains.kotlin.fir.declarations.utils.classId
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.isValidTypeParameterFromOuterDeclaration
import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.resolve.toTypeProjections
@@ -20,8 +22,25 @@ import org.jetbrains.kotlin.fir.types.*
object FirOuterClassArgumentsRequiredChecker : FirRegularClassChecker() {
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
// Checking the rest super types that weren't resolved on the first OUTER_CLASS_ARGUMENTS_REQUIRED check in FirTypeResolver
for (superTypeRef in declaration.superTypeRefs) {
checkOuterClassArgumentsRequired(superTypeRef, declaration, context, reporter)
val oldResolvePhase = declaration.resolvePhase
val oldList = declaration.superTypeRefs.toList()
try {
for (superTypeRef in declaration.superTypeRefs) {
checkOuterClassArgumentsRequired(superTypeRef, declaration, context, reporter)
}
} catch (e: ConcurrentModificationException) {
val newResolvePhase = declaration.resolvePhase
val newList = declaration.superTypeRefs.toList()
throw IllegalStateException(
"""
CME while traversing superTypeRefs of declaration=${declaration.render()}:
classId: ${declaration.classId},
oldPhase: $oldResolvePhase, oldList: ${oldList.joinToString { it.render() }},
newPhase: $newResolvePhase, newList: ${newList.joinToString { it.render() }}
""".trimIndent(), e
)
}
}