[FIR] FirResolvePhase: introduce isItAllowedToCallLazyResolveTo
To explicitly declare when it is possible to call lazy resolve
This commit is contained in:
committed by
Space Team
parent
f036954ac0
commit
c7765258d1
+1
-1
@@ -200,7 +200,7 @@ internal class LLFirLockProvider(private val checker: LLFirLazyResolveContractCh
|
||||
actionUnderLock: () -> Unit,
|
||||
actionOnCycle: () -> Unit,
|
||||
) {
|
||||
checker.lazyResolveToPhaseInside(phase, isJumpingPhase = true) {
|
||||
checker.lazyResolveToPhaseInside(phase) {
|
||||
target.withJumpingLockImpl(phase, actionUnderLock, actionOnCycle)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.isItAllowedToCallLazyResolveTo
|
||||
import org.jetbrains.kotlin.fir.symbols.FirLazyResolveContractViolationException
|
||||
|
||||
/**
|
||||
@@ -18,8 +19,9 @@ import org.jetbrains.kotlin.fir.symbols.FirLazyResolveContractViolationException
|
||||
internal class LLFirLazyResolveContractChecker {
|
||||
private val currentTransformerPhase = ThreadLocal.withInitial<FirResolvePhase?> { null }
|
||||
|
||||
inline fun lazyResolveToPhaseInside(phase: FirResolvePhase, isJumpingPhase: Boolean = false, resolve: () -> Unit) {
|
||||
checkIfCanLazyResolveToPhase(phase, isJumpingPhase)
|
||||
inline fun lazyResolveToPhaseInside(phase: FirResolvePhase, resolve: () -> Unit) {
|
||||
checkIfCanLazyResolveToPhase(phase)
|
||||
|
||||
val previousPhase = currentTransformerPhase.get()
|
||||
currentTransformerPhase.set(phase)
|
||||
try {
|
||||
@@ -29,10 +31,10 @@ internal class LLFirLazyResolveContractChecker {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun checkIfCanLazyResolveToPhase(requestedPhase: FirResolvePhase, isJumpingPhase: Boolean) {
|
||||
private fun checkIfCanLazyResolveToPhase(requestedPhase: FirResolvePhase) {
|
||||
val currentPhase = currentTransformerPhase.get() ?: return
|
||||
|
||||
if (requestedPhase > currentPhase || !isJumpingPhase && requestedPhase == currentPhase) {
|
||||
if (!currentPhase.isItAllowedToCallLazyResolveTo(requestedPhase)) {
|
||||
val exception = FirLazyResolveContractViolationException(currentPhase = currentPhase, requestedPhase = requestedPhase)
|
||||
if (System.getProperty("kotlin.suppress.lazy.resolve.contract.violation") != null) {
|
||||
LoggerHolder.LOG.warn(exception)
|
||||
|
||||
Reference in New Issue
Block a user