[AA] create psi-based pointer only for KtSymbolOrigin.SOURCE
^KT-54311
This commit is contained in:
committed by
Space Team
parent
119f6858cd
commit
9c30411bb3
+4
-7
@@ -35,23 +35,20 @@ public class KtPsiBasedSymbolPointer<S : KtSymbol>(private val psiPointer: Smart
|
||||
|
||||
public companion object {
|
||||
public fun <S : KtSymbol> createForSymbolFromSource(symbol: S): KtPsiBasedSymbolPointer<S>? {
|
||||
if (symbol.origin == KtSymbolOrigin.LIBRARY) return null
|
||||
if (symbol.origin != KtSymbolOrigin.SOURCE) return null
|
||||
|
||||
// If symbol points to a generated member, we won't be able to recover it later on, because there is no corresponding
|
||||
// psi by which it can be found
|
||||
if (symbol.origin == KtSymbolOrigin.SOURCE_MEMBER_GENERATED) return null
|
||||
|
||||
// (intersection | substitution) overrides are intermediate, non-materialized (i.e., fake) members, coming from super type(s).
|
||||
// Therefore, no corresponding psi either.
|
||||
if (symbol.origin == KtSymbolOrigin.INTERSECTION_OVERRIDE) return null
|
||||
if (symbol.origin == KtSymbolOrigin.SUBSTITUTION_OVERRIDE) return null
|
||||
|
||||
val psi = when (val psi = symbol.psi) {
|
||||
is KtDeclaration -> psi
|
||||
is KtFile -> psi
|
||||
is KtObjectLiteralExpression -> psi.objectDeclaration
|
||||
else -> null
|
||||
} ?: return null
|
||||
else -> return null
|
||||
}
|
||||
|
||||
return KtPsiBasedSymbolPointer(psi.createSmartPointer())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// DO_NOT_CHECK_SYMBOL_RESTORE
|
||||
// DO_NOT_CHECK_SYMBOL_RESTORE_K1
|
||||
|
||||
interface I {
|
||||
fun foo()
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// DO_NOT_CHECK_SYMBOL_RESTORE
|
||||
// DO_NOT_CHECK_SYMBOL_RESTORE_K1
|
||||
|
||||
interface I1 {
|
||||
fun foo()
|
||||
|
||||
Reference in New Issue
Block a user