[LL FIR] add ability to suppress contract violation exception

^KT-56543
This commit is contained in:
Dmitrii Gridin
2023-04-06 11:04:32 +02:00
committed by Space Team
parent 8387ea8a39
commit 2463b904f7
3 changed files with 29 additions and 15 deletions
@@ -44,6 +44,17 @@ abstract class FirLazyDeclarationResolver : FirSessionComponent {
abstract fun lazyResolveToPhaseWithCallableMembers(symbol: FirClassSymbol<*>, toPhase: FirResolvePhase)
}
class FirLazyResolveContractViolationException(
currentPhase: FirResolvePhase,
requestedPhase: FirResolvePhase,
) : IllegalStateException(
"""
`lazyResolveToPhase($requestedPhase)` cannot be called from a transformer with a phase $currentPhase.
`lazyResolveToPhase` can be called only from a transformer with a phase which is strictly greater than a requested phase;
i.e., `lazyResolveToPhase(A)` may be only called from a lazy transformer with a phase B, where A < B. This is a contract of lazy resolve
""".trimIndent()
)
val FirSession.lazyDeclarationResolver: FirLazyDeclarationResolver by FirSession.sessionComponentAccessor()
private val FirDeclaration.lazyDeclarationResolver get() = moduleData.session.lazyDeclarationResolver