FirEffectiveVisibilityResolver: search parent in containingDeclarations
When determining effective visibility of 'something', we use containing declarations from the context to find 'something' parent, to avoid calling getClassSymbolByFqName for all cases.
This commit is contained in:
+16
-11
@@ -68,20 +68,25 @@ class FirEffectiveVisibilityResolverImpl(private val session: FirSession) : FirE
|
|||||||
// TODO: fix
|
// TODO: fix
|
||||||
var succeededToGetSymbol = false
|
var succeededToGetSymbol = false
|
||||||
|
|
||||||
if (parentClassId?.isLocal == false) {
|
// look for the containing class
|
||||||
parentSymbol = session.firSymbolProvider.getClassLikeSymbolByFqName(parentClassId)
|
// in the containingDeclarations or
|
||||||
parentSymbol?.fir.safeAs<FirMemberDeclaration>()?.let {
|
// try using the firSymbolProvider
|
||||||
succeededToGetSymbol = true
|
if (parentClassId != null && containingDeclarations != null) {
|
||||||
parentEffectiveVisibility = resolveFor(it, null, scopeSession)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we suppose we can't ever get a local classId
|
|
||||||
// of some fir from outside of our containing declarations
|
|
||||||
if (!succeededToGetSymbol && parentClassId != null && containingDeclarations != null) {
|
|
||||||
parentClassId.findOuterContainerInfo(containingDeclarations, scopeSession)?.let {
|
parentClassId.findOuterContainerInfo(containingDeclarations, scopeSession)?.let {
|
||||||
parentSymbol = it.first
|
parentSymbol = it.first
|
||||||
parentEffectiveVisibility = it.second
|
parentEffectiveVisibility = it.second
|
||||||
|
succeededToGetSymbol = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!succeededToGetSymbol) {
|
||||||
|
if (parentClassId?.isLocal == false) {
|
||||||
|
parentSymbol = session.firSymbolProvider.getClassLikeSymbolByFqName(parentClassId)
|
||||||
|
parentSymbol?.fir.safeAs<FirMemberDeclaration>()?.let {
|
||||||
|
parentEffectiveVisibility = resolveFor(it, null, scopeSession)
|
||||||
|
}
|
||||||
|
} else if (parentClassId?.isLocal == true) {
|
||||||
|
parentEffectiveVisibility = FirEffectiveVisibilityImpl.Local
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user