[FIR] Fix exposed visibility checking for enum entries

This commit is contained in:
Mikhail Glukhikh
2020-08-20 13:01:22 +03:00
parent e15e87fded
commit 8e2c5bf4fe
3 changed files with 36 additions and 1 deletions
@@ -6,4 +6,12 @@ class A {
abstract class B { abstract class B {
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(str: String): A.InnerA fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(str: String): A.InnerA
} }
private enum class Some {
FIRST {
override fun foo(): Some = FIRST
};
abstract fun foo(): Some
}
@@ -20,3 +20,28 @@ FILE: exposedFunctionReturnType.kt
public final fun foo(str: R|kotlin/String|): R|A.InnerA| public final fun foo(str: R|kotlin/String|): R|A.InnerA|
} }
private final enum class Some : R|kotlin/Enum<Some>| {
private constructor(): R|Some| {
super<R|kotlin/Enum<Some>|>()
}
public final static enum entry FIRST: R|Some| = object : R|Some| {
private constructor(): R|<anonymous>| {
super<R|Some|>()
}
public final override fun foo(): R|Some| {
^foo R|/Some.FIRST|
}
}
public abstract fun foo(): R|Some|
public final static fun values(): R|kotlin/Array<Some>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|Some| {
}
}
@@ -81,7 +81,9 @@ class FirEffectiveVisibilityResolverImpl(private val session: FirSession) : FirE
if (!succeededToGetSymbol) { if (!succeededToGetSymbol) {
if (parentClassId?.isLocal == false) { if (parentClassId?.isLocal == false) {
// ?: is needed to get enum from enum entry
parentSymbol = session.firSymbolProvider.getClassLikeSymbolByFqName(parentClassId) parentSymbol = session.firSymbolProvider.getClassLikeSymbolByFqName(parentClassId)
?: parentClassId.outerClassId?.let { session.firSymbolProvider.getClassLikeSymbolByFqName(it) }
parentSymbol?.fir.safeAs<FirMemberDeclaration>()?.let { parentSymbol?.fir.safeAs<FirMemberDeclaration>()?.let {
parentEffectiveVisibility = resolveFor(it, null, scopeSession) parentEffectiveVisibility = resolveFor(it, null, scopeSession)
} }