diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index 30f6c041790..dc011169304 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -222,7 +222,7 @@ class FirTowerResolver( } val implicitScope = implicitReceiverValue.implicitScope if (implicitScope != null) { - // Regular implicit receiver scope (outer objects only?) + // Regular implicit receiver scope (outer objects, statics) // object Outer { // val x = 0 // class Nested { val y = x } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt index 9f82693a518..34d89c25b49 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt @@ -270,6 +270,7 @@ class QualifiedReceiverTowerLevel( fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? { // TODO: this is not true atCall least for inner class constructors if (this is FirConstructor) return null + if ((this as? FirMemberDeclaration)?.isStatic == true) return null val id = this.symbol.callableId.classId ?: return null val symbol = session.firSymbolProvider.getClassLikeSymbolByFqName(id) as? FirClassSymbol ?: return null diff --git a/compiler/fir/resolve/testData/resolve/enumWithCompanion.kt b/compiler/fir/resolve/testData/resolve/enumWithCompanion.kt new file mode 100644 index 00000000000..2ef149197b8 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/enumWithCompanion.kt @@ -0,0 +1,11 @@ +enum class EC { + A, B; + companion object { + fun u(ec: EC): Boolean { + return when (ec) { + A -> true + B -> false + } + } + } +} diff --git a/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt b/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt new file mode 100644 index 00000000000..5ef31d3cc57 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/enumWithCompanion.txt @@ -0,0 +1,50 @@ +FILE: enumWithCompanion.kt + public final enum class EC : R|kotlin/Enum| { + private constructor(): R|EC| { + super|>() + } + + public final static val A: R|EC| = object : R|EC| { + private constructor(): R|EC| { + super() + } + + } + + + + public final static val B: R|EC| = object : R|EC| { + private constructor(): R|EC| { + super() + } + + } + + + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|EC.Companion| { + super() + } + + public final fun u(ec: R|EC|): R|kotlin/Boolean| { + ^u when (R|/ec|) { + ==($subj$, R|/EC.A|) -> { + Boolean(true) + } + ==($subj$, R|/EC.B|) -> { + Boolean(false) + } + } + + } + + } + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|EC| { + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 2aaa453a16c..72929952d0f 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -73,6 +73,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { 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") public void testExhaustiveness_boolean() throws Exception { runTest("compiler/fir/resolve/testData/resolve/exhaustiveness_boolean.kt");