FIR: introduce symbolProvider.getNestedClassifierScope to choose lazy/non-lazy
For some reason this breaks two old FE based tests with member type aliases. It's not very interesting because member aliases aren't supported.
This commit is contained in:
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirSuperTypeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.toFirSourceElement
|
||||
@@ -64,6 +65,21 @@ class JavaSymbolProvider(
|
||||
override fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): List<FirCallableSymbol<*>> =
|
||||
emptyList()
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
val symbol = this.getClassLikeSymbolByFqName(classId) ?: return null
|
||||
val regularClass = symbol.fir
|
||||
return if (regularClass is FirJavaClass) {
|
||||
nestedClassifierScope(
|
||||
classId,
|
||||
session,
|
||||
existingNames = regularClass.existingNestedClassifierNames,
|
||||
symbolProvider = this
|
||||
)
|
||||
} else {
|
||||
nestedClassifierScope(regularClass)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClassUseSiteMemberScope(
|
||||
classId: ClassId,
|
||||
useSiteSession: FirSession,
|
||||
|
||||
+7
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||
@@ -392,6 +393,12 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
return findRegularClass(classId)?.let {
|
||||
nestedClassifierScope(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPackageParts(packageFqName: FqName): Collection<PackagePartsCacheData> {
|
||||
return packagePartsCache.getOrPut(packageFqName) {
|
||||
try {
|
||||
|
||||
@@ -53,6 +53,8 @@ abstract class FirSymbolProvider : FirSessionComponent {
|
||||
|
||||
abstract fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): List<FirCallableSymbol<*>>
|
||||
|
||||
abstract fun getNestedClassifierScope(classId: ClassId): FirScope?
|
||||
|
||||
abstract fun getClassUseSiteMemberScope(
|
||||
classId: ClassId,
|
||||
useSiteSession: FirSession,
|
||||
|
||||
+4
@@ -29,6 +29,10 @@ class FirCompositeSymbolProvider(val providers: List<FirSymbolProvider>) : FirSy
|
||||
return providers.flatMap { it.getTopLevelCallableSymbols(packageFqName, name) }
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
return providers.firstNotNullResult { it.getNestedClassifierScope(classId) }
|
||||
}
|
||||
|
||||
override fun getPackage(fqName: FqName): FqName? {
|
||||
return providers.firstNotNullResult { it.getPackage(fqName) }
|
||||
}
|
||||
|
||||
+4
@@ -33,6 +33,10 @@ class FirDependenciesSymbolProviderImpl(val session: FirSession) : AbstractFirSy
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
return dependencyProviders.firstNotNullResult { it.getNestedClassifierScope(classId) }
|
||||
}
|
||||
|
||||
override fun getClassLikeSymbolByFqName(classId: ClassId): FirClassLikeSymbol<*>? {
|
||||
return classCache.lookupCacheOrCalculate(classId) {
|
||||
for (provider in dependencyProviders) {
|
||||
|
||||
+7
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.getOrPut
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
@@ -264,6 +265,12 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
return findRegularClass(classId)?.let {
|
||||
nestedClassifierScope(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllCallableNamesInPackage(fqName: FqName): Set<Name> {
|
||||
return allPackageFragments[fqName]?.flatMapTo(mutableSetOf()) {
|
||||
it.getAllCallableNames()
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -38,6 +39,12 @@ class FirProviderImpl(val session: FirSession) : FirProvider() {
|
||||
return (state.callableMap[CallableId(packageFqName, null, name)] ?: emptyList())
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
return (getFirClassifierByFqName(classId) as? FirRegularClass)?.let {
|
||||
nestedClassifierScope(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFirClassifierContainerFile(fqName: ClassId): FirFile {
|
||||
return state.classifierContainerFileMap[fqName] ?: error("Couldn't find container for $fqName")
|
||||
}
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirCompositeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirMemberTypeParameterScope
|
||||
@@ -37,8 +38,8 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(
|
||||
return withScopeCleanup {
|
||||
// ? Is it Ok to use original file session here ?
|
||||
lookupSuperTypes(regularClass, lookupInterfaces = false, deep = true, useSiteSession = session)
|
||||
.asReversed().mapTo(towerScope.scopes) {
|
||||
nestedClassifierScope(it.lookupTag.classId, session)
|
||||
.asReversed().mapNotNullTo(towerScope.scopes) {
|
||||
session.firSymbolProvider.getNestedClassifierScope(it.lookupTag.classId)
|
||||
}
|
||||
regularClass.addTypeParametersScope()
|
||||
val companionObject = regularClass.companionObject
|
||||
|
||||
+2
-2
@@ -108,8 +108,8 @@ private fun createScopesForNestedClasses(
|
||||
regularClass,
|
||||
lookupInterfaces = false, deep = true, useSiteSession = session,
|
||||
supertypeSupplier = supertypeComputationSession.supertypesSupplier
|
||||
).asReversed().mapTo(this) {
|
||||
nestedClassifierScope(it.lookupTag.classId, session)
|
||||
).asReversed().mapNotNullTo(this) {
|
||||
session.firSymbolProvider.getNestedClassifierScope(it.lookupTag.classId)
|
||||
}
|
||||
addIfNotNull(regularClass.typeParametersScope())
|
||||
val companionObjects = regularClass.declarations.filterIsInstance<FirRegularClass>().filter { it.isCompanion }
|
||||
|
||||
Vendored
+2
-2
@@ -20,7 +20,7 @@ class A : Outer<Double, Short>() {
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<String, Int>.Inner<Char>>() }
|
||||
Derived().baz() checkType { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, String>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, String>>() }
|
||||
A.B().bar() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Float, Long>.Inner<String>>() }
|
||||
A.B().x() checkType { <!UNRESOLVED_REFERENCE!>_<!><Map<String, Float>>() }
|
||||
A.B().x() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<String, Float>>() }
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,5 +15,5 @@ class Derived : BaseDerived2<Int>() {
|
||||
|
||||
fun foo() {
|
||||
Derived().foo() checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int, String>.Inner<Char>>() }
|
||||
Derived().baz() checkType { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, Int>>() }
|
||||
Derived().baz() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Map<Char, Int>>() }
|
||||
}
|
||||
|
||||
@@ -141,6 +141,11 @@ class IdeFirProvider(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNestedClassifierScope(classId: ClassId): FirScope? {
|
||||
getFirClassifierByFqName(classId)
|
||||
return cacheProvider.getNestedClassifierScope(classId)
|
||||
}
|
||||
|
||||
override fun getClassUseSiteMemberScope(classId: ClassId, useSiteSession: FirSession, scopeSession: ScopeSession): FirScope? {
|
||||
getFirClassifierByFqName(classId)
|
||||
return cacheProvider.getClassUseSiteMemberScope(classId, useSiteSession, scopeSession)
|
||||
|
||||
Reference in New Issue
Block a user