[FIR] Make statics visible from nested companion/classes
This commit is contained in:
@@ -222,7 +222,7 @@ class FirTowerResolver(
|
|||||||
}
|
}
|
||||||
val implicitScope = implicitReceiverValue.implicitScope
|
val implicitScope = implicitReceiverValue.implicitScope
|
||||||
if (implicitScope != null) {
|
if (implicitScope != null) {
|
||||||
// Regular implicit receiver scope (outer objects only?)
|
// Regular implicit receiver scope (outer objects, statics)
|
||||||
// object Outer {
|
// object Outer {
|
||||||
// val x = 0
|
// val x = 0
|
||||||
// class Nested { val y = x }
|
// class Nested { val y = x }
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ class QualifiedReceiverTowerLevel(
|
|||||||
fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? {
|
fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? {
|
||||||
// TODO: this is not true atCall least for inner class constructors
|
// TODO: this is not true atCall least for inner class constructors
|
||||||
if (this is FirConstructor) return null
|
if (this is FirConstructor) return null
|
||||||
|
if ((this as? FirMemberDeclaration)?.isStatic == true) return null
|
||||||
val id = this.symbol.callableId.classId ?: return null
|
val id = this.symbol.callableId.classId ?: return null
|
||||||
val symbol = session.firSymbolProvider.getClassLikeSymbolByFqName(id) as? FirClassSymbol ?: return null
|
val symbol = session.firSymbolProvider.getClassLikeSymbolByFqName(id) as? FirClassSymbol ?: return null
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
enum class EC {
|
||||||
|
A, B;
|
||||||
|
companion object {
|
||||||
|
fun u(ec: EC): Boolean {
|
||||||
|
return when (ec) {
|
||||||
|
A -> true
|
||||||
|
B -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
FILE: enumWithCompanion.kt
|
||||||
|
public final enum class EC : R|kotlin/Enum<EC>| {
|
||||||
|
private constructor(): R|EC| {
|
||||||
|
super<R|kotlin/Enum<EC>|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static val A: R|EC| = object : R|EC| {
|
||||||
|
private constructor(): R|EC| {
|
||||||
|
super<R|EC|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public final static val B: R|EC| = object : R|EC| {
|
||||||
|
private constructor(): R|EC| {
|
||||||
|
super<R|EC|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public final companion object Companion : R|kotlin/Any| {
|
||||||
|
private constructor(): R|EC.Companion| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun u(ec: R|EC|): R|kotlin/Boolean| {
|
||||||
|
^u when (R|<local>/ec|) {
|
||||||
|
==($subj$, R|/EC.A|) -> {
|
||||||
|
Boolean(true)
|
||||||
|
}
|
||||||
|
==($subj$, R|/EC.B|) -> {
|
||||||
|
Boolean(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static fun values(): R|kotlin/Array<EC>| {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static fun valueOf(value: R|kotlin/String|): R|EC| {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
@@ -73,6 +73,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
|||||||
runTest("compiler/fir/resolve/testData/resolve/enum.kt");
|
runTest("compiler/fir/resolve/testData/resolve/enum.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumWithCompanion.kt")
|
||||||
|
public void testEnumWithCompanion() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/enumWithCompanion.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("exhaustiveness_boolean.kt")
|
@TestMetadata("exhaustiveness_boolean.kt")
|
||||||
public void testExhaustiveness_boolean() throws Exception {
|
public void testExhaustiveness_boolean() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/exhaustiveness_boolean.kt");
|
runTest("compiler/fir/resolve/testData/resolve/exhaustiveness_boolean.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user