FIR IDE: fix IDE exception in presence of non-top-level type alias

Finding type alias doesn't work if it's not top level because the class
ID doesn't match. There doesn't seem to be a easy way to make it work
so this commit simply makes the IDE tolerate it.
This commit is contained in:
Tianyu Geng
2021-03-23 17:48:58 -07:00
committed by Mikhail Glukhikh
parent 19708cfa87
commit 6ca005cd70
2 changed files with 5 additions and 4 deletions
@@ -124,11 +124,11 @@ private fun KtClassOrObject.findFir(firSymbolProvider: FirSymbolProvider): FirRe
}
}
private fun KtTypeAlias.findFir(firSymbolProvider: FirSymbolProvider): FirTypeAlias {
private fun KtTypeAlias.findFir(firSymbolProvider: FirSymbolProvider): FirTypeAlias? {
val typeAlias = ClassId(containingKtFile.packageFqName, nameAsSafeName)
return executeWithoutPCE {
// Finding a non-top-level type alias won't work
firSymbolProvider.getClassLikeSymbolByFqName(typeAlias)?.fir as? FirTypeAlias
?: error("Could not find type alias $typeAlias")
}
}
@@ -28,10 +28,11 @@ internal inline fun <T> executeOrReturnDefaultValueOnPCE(defaultValue: T, action
defaultValue
}
internal inline fun <T : Any> executeWithoutPCE(crossinline action: () -> T): T {
internal inline fun <T> executeWithoutPCE(crossinline action: () -> T): T {
var result: T? = null
ProgressManager.getInstance().executeNonCancelableSection { result = action() }
return result!!
@Suppress("UNCHECKED_CAST")
return result as T
}
internal inline fun <T> Lock.lockWithPCECheck(lockingIntervalMs: Long, action: () -> T): T {