FIR: Fix getNestedClassifierScope for local classes
This commit is contained in:
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTagWithFixedSymbol
|
||||
@@ -59,6 +60,12 @@ abstract class FirSymbolProvider : FirSessionComponent {
|
||||
}
|
||||
}
|
||||
|
||||
fun FirSession.getNestedClassifierScope(lookupTag: ConeClassLikeLookupTag): FirScope? =
|
||||
when (lookupTag) {
|
||||
is ConeClassLookupTagWithFixedSymbol -> nestedClassifierScope(lookupTag.symbol.fir)
|
||||
else -> firSymbolProvider.getNestedClassifierScope(lookupTag.classId)
|
||||
}
|
||||
|
||||
fun FirSymbolProvider.getClassDeclaredCallableSymbols(classId: ClassId, name: Name): List<FirCallableSymbol<*>> {
|
||||
val classSymbol = getClassLikeSymbolByFqName(classId) as? FirRegularClassSymbol ?: return emptyList()
|
||||
val declaredMemberScope = declaredMemberScope(classSymbol.fir)
|
||||
|
||||
+6
-3
@@ -5,9 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.getNestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
@@ -36,7 +39,7 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(
|
||||
// ? Is it Ok to use original file session here ?
|
||||
val superTypes = lookupSuperTypes(regularClass, lookupInterfaces = false, deep = true, useSiteSession = session).asReversed()
|
||||
for (superType in superTypes) {
|
||||
session.firSymbolProvider.getNestedClassifierScope(superType.lookupTag.classId)?.let {
|
||||
session.getNestedClassifierScope(superType.lookupTag)?.let {
|
||||
towerScope.addScope(it)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ private fun createScopesForNestedClasses(
|
||||
lookupInterfaces = false, deep = true, useSiteSession = session,
|
||||
supertypeSupplier = supertypeComputationSession.supertypesSupplier
|
||||
).asReversed().mapNotNullTo(this) {
|
||||
session.firSymbolProvider.getNestedClassifierScope(it.lookupTag.classId)
|
||||
session.getNestedClassifierScope(it.lookupTag)
|
||||
}
|
||||
addIfNotNull(klass.typeParametersScope())
|
||||
val companionObjects = klass.declarations.filterIsInstance<FirRegularClass>().filter { it.isCompanion }
|
||||
|
||||
Reference in New Issue
Block a user