From 447e1711da50244638d72a70d32fed5273f8d45e Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Fri, 19 May 2023 17:16:22 +0200 Subject: [PATCH] [LL FIR] do not update phase if exception occurred MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exception (even PCE) can lead to inconsistent situations, for example, where a function can be marked as resolved, but arguments – not. Also, in this case, it is possible that the function will be marked as resolved to TYPES, but not all its type really resolved ^KTIJ-25582 Fixed --- .../low/level/api/fir/file/builder/LLFirLockProvider.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/builder/LLFirLockProvider.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/builder/LLFirLockProvider.kt index ebd18394919..63b2f2620d4 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/builder/LLFirLockProvider.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/builder/LLFirLockProvider.kt @@ -171,10 +171,15 @@ internal class LLFirLockProvider(private val checker: LLFirLazyResolveContractCh is FirResolvedToPhaseState -> { if (!tryLock(toPhase, stateSnapshot)) continue + + var exceptionOccurred = false try { action() + } catch (e: Throwable) { + exceptionOccurred = true + throw e } finally { - val newPhase = if (updatePhase) toPhase else stateSnapshot.resolvePhase + val newPhase = if (updatePhase && !exceptionOccurred) toPhase else stateSnapshot.resolvePhase unlock(toPhase = newPhase) }