[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? {
|
||||
val regularPointer = runCatching(::createPointer).let {
|
||||
val regularPointer = runCatching {
|
||||
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(disable = false, action = ::createPointer)
|
||||
}.let {
|
||||
if (directiveToIgnoreSymbolRestore == null) it.getOrThrow() else it.getOrNull()
|
||||
} ?: return null
|
||||
|
||||
val nonPsiPointer = kotlin.runCatching {
|
||||
if (this is KtFileSymbol) return@runCatching null
|
||||
|
||||
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(::createPointer)
|
||||
KtPsiBasedSymbolPointer.withDisabledPsiBasedPointers(disable = true, action = ::createPointer)
|
||||
}
|
||||
|
||||
return PointerWrapper(
|
||||
|
||||
+5
-7
@@ -56,13 +56,11 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol> private constructor(private v
|
||||
|
||||
@TestOnly
|
||||
@Synchronized
|
||||
public fun <T> withDisabledPsiBasedPointers(action: () -> T): T {
|
||||
disablePsiPointer = true
|
||||
return try {
|
||||
action()
|
||||
} finally {
|
||||
disablePsiPointer = false
|
||||
}
|
||||
public fun <T> withDisabledPsiBasedPointers(disable: Boolean, action: () -> T): T = try {
|
||||
disablePsiPointer = disable
|
||||
action()
|
||||
} finally {
|
||||
disablePsiPointer = false
|
||||
}
|
||||
|
||||
@Volatile
|
||||
|
||||
Reference in New Issue
Block a user