[AA] AbstractSymbolTest: fix race
^KT-54311
This commit is contained in:
committed by
Space Team
parent
47c9618b79
commit
7d1ac0ac97
+4
-2
@@ -57,14 +57,16 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiSingleFileTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KtSymbol.safePointer(): PointerWrapper? {
|
fun KtSymbol.safePointer(): PointerWrapper? {
|
||||||
val regularPointer = runCatching(::createPointer).let {
|
val regularPointer = runCatching {
|
||||||
|
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(disable = false, action = ::createPointer)
|
||||||
|
}.let {
|
||||||
if (directiveToIgnoreSymbolRestore == null) it.getOrThrow() else it.getOrNull()
|
if (directiveToIgnoreSymbolRestore == null) it.getOrThrow() else it.getOrNull()
|
||||||
} ?: return null
|
} ?: return null
|
||||||
|
|
||||||
val nonPsiPointer = kotlin.runCatching {
|
val nonPsiPointer = kotlin.runCatching {
|
||||||
if (this is KtFileSymbol) return@runCatching null
|
if (this is KtFileSymbol) return@runCatching null
|
||||||
|
|
||||||
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(::createPointer)
|
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(disable = true, action = ::createPointer)
|
||||||
}
|
}
|
||||||
|
|
||||||
return PointerWrapper(
|
return PointerWrapper(
|
||||||
|
|||||||
+5
-7
@@ -56,13 +56,11 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(private v
|
|||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
@Synchronized
|
@Synchronized
|
||||||
public fun <T> withDisabledPsiBasedPointers(action: () -> T): T {
|
public fun <T> withDisabledPsiBasedPointers(disable: Boolean, action: () -> T): T = try {
|
||||||
disablePsiPointer = true
|
disablePsiPointer = disable
|
||||||
return try {
|
action()
|
||||||
action()
|
} finally {
|
||||||
} finally {
|
disablePsiPointer = false
|
||||||
disablePsiPointer = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
|
|||||||
Reference in New Issue
Block a user