[LL FIR] adapt RawFirNonLocalDeclarationBuilder for new FirDesignation
Effectively nothing changed right now, but now it is possible to process `FirScript` as `containingDeclaration` inside `moveNext` ^KT-65345
This commit is contained in:
committed by
Space Team
parent
eb8e3f64f0
commit
9b60e5ca06
+1
-6
@@ -102,11 +102,6 @@ class FirDesignation(
|
||||
}
|
||||
|
||||
val scriptOrNull: FirScript? get() = path.getOrNull(0) as? FirScript ?: path.getOrNull(1) as? FirScript ?: target as? FirScript
|
||||
|
||||
/**
|
||||
* This property exists only for compatibility and should be dropped after KT-65345
|
||||
*/
|
||||
val classPath: List<FirRegularClass> get() = path.filterIsInstance<FirRegularClass>()
|
||||
}
|
||||
|
||||
fun ExceptionAttachmentBuilder.withFirDesignationEntry(name: String, designation: FirDesignation) {
|
||||
@@ -132,7 +127,7 @@ private fun collectDesignationPath(target: FirElementWithResolveState): List<Fir
|
||||
is FirConstructor,
|
||||
is FirEnumEntry,
|
||||
is FirPropertyAccessor,
|
||||
is FirErrorProperty
|
||||
is FirErrorProperty,
|
||||
-> {
|
||||
requireIsInstance<FirCallableDeclaration>(target)
|
||||
// We shouldn't try to build a designation path for such fake declarations as they
|
||||
|
||||
+5
-3
@@ -99,13 +99,14 @@ internal class RawFirNonLocalDeclarationBuilder private constructor(
|
||||
functionsToRebind = functionsToRebind,
|
||||
replacementApplier = replacementApplier
|
||||
)
|
||||
|
||||
builder.context.packageFqName = rootNonLocalDeclaration.containingKtFile.packageFqName
|
||||
if (rebindContainingSymbol) {
|
||||
@OptIn(PrivateForInline::class)
|
||||
builder.context.forcedContainerSymbol = designation.target.symbol
|
||||
}
|
||||
|
||||
return builder.moveNext(designation.classPath.iterator(), containingClass = null)
|
||||
return builder.moveNext(designation.path.iterator(), containingDeclaration = null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,8 +317,9 @@ internal class RawFirNonLocalDeclarationBuilder private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun moveNext(iterator: Iterator<FirDeclaration>, containingClass: FirRegularClass?): FirDeclaration {
|
||||
private fun moveNext(iterator: Iterator<FirDeclaration>, containingDeclaration: FirDeclaration?): FirDeclaration {
|
||||
if (!iterator.hasNext()) {
|
||||
val containingClass = containingDeclaration as? FirRegularClass
|
||||
val visitor = VisitorWithReplacement(containingClass)
|
||||
return when (declarationToBuild) {
|
||||
is KtProperty -> {
|
||||
@@ -350,7 +352,7 @@ internal class RawFirNonLocalDeclarationBuilder private constructor(
|
||||
}
|
||||
|
||||
val parent = iterator.next()
|
||||
if (parent !is FirRegularClass) return moveNext(iterator, containingClass = null)
|
||||
if (parent !is FirRegularClass) return moveNext(iterator, containingDeclaration = null)
|
||||
|
||||
val classOrObject = parent.psi
|
||||
if (classOrObject !is KtClassOrObject) {
|
||||
|
||||
Reference in New Issue
Block a user