diff --git a/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt b/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt new file mode 100644 index 00000000000..5abbfe98669 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt @@ -0,0 +1,10 @@ +enum class A { + X, Y; + companion object { + fun foo(): Int { + return 1 + } + } + + fun foo(): Int = Companion.foo() +} diff --git a/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.txt b/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.txt new file mode 100644 index 00000000000..85480189a3d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.txt @@ -0,0 +1,30 @@ +FILE: companionAccessInEnum.kt + public final enum class A : R|kotlin/Enum| { + private constructor(): R|A| { + super|>() + } + + public final static enum entry X: R|A| + public final static enum entry Y: R|A| + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|A.Companion| { + super() + } + + public final fun foo(): R|kotlin/Int| { + ^foo Int(1) + } + + } + + public final fun foo(): R|kotlin/Int| { + ^foo Q|A.Companion|.R|/A.Companion.foo|() + } + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|A| { + } + + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index f27a0c6195d..6870b7065fe 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -48,6 +48,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/companion.kt"); } + @TestMetadata("companionAccessInEnum.kt") + public void testCompanionAccessInEnum() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt"); + } + @TestMetadata("companionObjectCall.kt") public void testCompanionObjectCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 85ff23a849a..3bd412f016e 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -48,6 +48,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/companion.kt"); } + @TestMetadata("companionAccessInEnum.kt") + public void testCompanionAccessInEnum() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt"); + } + @TestMetadata("companionObjectCall.kt") public void testCompanionObjectCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 77229a68ec6..3b0a2d8f0b9 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -48,6 +48,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/companion.kt"); } + @TestMetadata("companionAccessInEnum.kt") + public void testCompanionAccessInEnum() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/companionAccessInEnum.kt"); + } + @TestMetadata("companionObjectCall.kt") public void testCompanionObjectCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt"); diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt index 7c302a8aac7..c27fa46eb11 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt @@ -148,13 +148,7 @@ class MemberScopeTowerLevel( } ) } - TowerScopeLevel.Token.Objects -> processMembers(processor) { consumer -> - this.processClassifiersByName(name) { - // WARNING, DO NOT CAST FUNCTIONAL TYPE ITSELF - @Suppress("UNCHECKED_CAST") - consumer(it as T) - } - } + TowerScopeLevel.Token.Objects -> ProcessorAction.NEXT } } diff --git a/compiler/testData/codegen/box/enum/objectInEnum.kt b/compiler/testData/codegen/box/enum/objectInEnum.kt index 6b22f24cdce..a177645e9a0 100644 --- a/compiler/testData/codegen/box/enum/objectInEnum.kt +++ b/compiler/testData/codegen/box/enum/objectInEnum.kt @@ -1,5 +1,4 @@ // !LANGUAGE: -NestedClassesInEnumEntryShouldBeInner -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE enum class E { diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.fir.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.fir.kt index e50193d6d83..68fe795f84c 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.fir.kt @@ -28,7 +28,7 @@ object O { fun f() { A.c A.hashCode() - A().Nested + A().Nested A.Nested() A().Inner() A.Companion.Nested @@ -42,10 +42,10 @@ fun f() { A.Companion.c A.Obj A.Companion.Obj2 - A.Obj2 - A.Obj2.c - A.Nested2 + A.Obj2 + A.Obj2.c + A.Nested2 O.O O.A() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.fir.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.fir.kt index bd84df04f12..fe5a977f93d 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.fir.kt @@ -33,12 +33,12 @@ enum class C { } fun f() { - C.E1.A + C.E1.A C.E1.A() C.E2.B() - C.E2.O - C.E3.O.InO + C.E2.O + C.E3.O.InO C.O C.O.InO diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.fir.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.fir.kt index b4178c69923..21659f70c73 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.fir.kt @@ -33,12 +33,12 @@ enum class C { } fun f() { - C.E1.A + C.E1.A C.E1.A() C.E2.B() - C.E2.O - C.E3.O.InO + C.E2.O + C.E3.O.InO C.O C.O.InO diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/enumCompanionInterdependence.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/enumCompanionInterdependence.fir.kt index ef40ac1e577..79dc1230d06 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/enumCompanionInterdependence.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/enumCompanionInterdependence.fir.kt @@ -31,7 +31,7 @@ enum class Fruit(personal: Int) { // Another example from KT-11769 enum class EnumCompanion1(val x: Int) { - INSTANCE(Companion.foo()), + INSTANCE(Companion.foo()), ANOTHER(foo()); companion object { diff --git a/compiler/testData/diagnostics/tests/inner/nestedClassAccessedViaInstanceReference.fir.kt b/compiler/testData/diagnostics/tests/inner/nestedClassAccessedViaInstanceReference.fir.kt index 69bdc184c13..5a56033aae3 100644 --- a/compiler/testData/diagnostics/tests/inner/nestedClassAccessedViaInstanceReference.fir.kt +++ b/compiler/testData/diagnostics/tests/inner/nestedClassAccessedViaInstanceReference.fir.kt @@ -25,29 +25,29 @@ object Obj { fun test(with: WithClassObject, without: WithoutClassObject, obj: Obj) { with.Nested() - with.NestedWithClassObject + with.NestedWithClassObject with.NestedWithClassObject() - with.NestedWithClassObject.foo() - with.NestedEnum.A - with.NestedObj - with.NestedObj() - with.NestedObj.foo() + with.NestedWithClassObject.foo() + with.NestedEnum.A + with.NestedObj + with.NestedObj() + with.NestedObj.foo() without.Nested() - without.NestedWithClassObject + without.NestedWithClassObject without.NestedWithClassObject() - without.NestedWithClassObject.foo() - without.NestedEnum.A - without.NestedObj - without.NestedObj() - without.NestedObj.foo() + without.NestedWithClassObject.foo() + without.NestedEnum.A + without.NestedObj + without.NestedObj() + without.NestedObj.foo() obj.Nested() - obj.NestedWithClassObject + obj.NestedWithClassObject obj.NestedWithClassObject() - obj.NestedWithClassObject.foo() - obj.NestedEnum.A - obj.NestedObj - obj.NestedObj() - obj.NestedObj.foo() -} \ No newline at end of file + obj.NestedWithClassObject.foo() + obj.NestedEnum.A + obj.NestedObj + obj.NestedObj() + obj.NestedObj.foo() +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesNew.fir.kt b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesNew.fir.kt index 010fca061ef..ac17886b6d9 100644 --- a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesNew.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesNew.fir.kt @@ -119,8 +119,8 @@ class C : O.B() { val b = A::foo // DEPRECATED: Classifiers from companions of direct superclasses - val e = FromCompanionA::foo - val f = FromCompanionB::foo + val e = FromCompanionA::foo + val f = FromCompanionB::foo // INVISIBLE: "cousin" supertypes themselves val g = Alpha::foo @@ -128,9 +128,9 @@ class C : O.B() { val i = Gamma::foo // DEPRECATED: classifiers from "cousin" superclasses - val k = FromAlpha::foo - val l = FromBeta::foo - val m = FromGamma::foo + val k = FromAlpha::foo + val l = FromBeta::foo + val m = FromGamma::foo // INVISIBLE: We don't see classifiers from companions of "cousin" superclasses val o = FromCompanionAlpha::foo @@ -138,5 +138,5 @@ class C : O.B() { val q = FromCompanionGamma::foo // DEPRECATED: Classifiers from supertypes of our own companion - val r = FromDelta::foo -} \ No newline at end of file + val r = FromDelta::foo +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOld.fir.kt b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOld.fir.kt index 5cf582c3d69..e258166f58b 100644 --- a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOld.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOld.fir.kt @@ -119,8 +119,8 @@ class C : O.B() { val b = A::foo // DEPRECATED: Classifiers from companions of direct superclasses - val e = FromCompanionA::foo - val f = FromCompanionB::foo + val e = FromCompanionA::foo + val f = FromCompanionB::foo // INVISIBLE: "cousin" supertypes themselves val g = Alpha::foo @@ -128,9 +128,9 @@ class C : O.B() { val i = Gamma::foo // DEPRECATED: classifiers from "cousin" superclasses - val k = FromAlpha::foo - val l = FromBeta::foo - val m = FromGamma::foo + val k = FromAlpha::foo + val l = FromBeta::foo + val m = FromGamma::foo // INVISIBLE: We don't see classifiers from companions of "cousin" superclasses val o = FromCompanionAlpha::foo @@ -138,5 +138,5 @@ class C : O.B() { val q = FromCompanionGamma::foo // DEPRECATED: Classifiers from supertypes of our own companion - val r = FromDelta::foo -} \ No newline at end of file + val r = FromDelta::foo +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOldComplexCases.fir.kt b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOldComplexCases.fir.kt index 5902f6f0990..04396ecf509 100644 --- a/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOldComplexCases.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/kt21515/callableReferencesOldComplexCases.fir.kt @@ -12,7 +12,7 @@ object A { } class Derived : Base() { - val a = FromBaseCompanion::foo + val a = FromBaseCompanion::foo } } @@ -30,7 +30,7 @@ object B { } class Derived : Base() { - val a = FromBaseCompanion::foo + val a = FromBaseCompanion::foo } } @@ -48,7 +48,7 @@ object C { } class Derived : Base() { - val a = FromBaseCompanion::foo + val a = FromBaseCompanion::foo } } @@ -64,6 +64,6 @@ object D { } class Derived : Base() { - val a = FromBaseCompanion::foo + val a = FromBaseCompanion::foo } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt b/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt index daaac36cf4b..8b825b6359c 100644 --- a/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt @@ -5,11 +5,11 @@ fun foo() { val b = object { object c {} } - b.c + b.c class A { object d {} } val f = { object e {} } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt index e9d9b4acc49..271c98176b8 100644 --- a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt @@ -32,8 +32,8 @@ fun testY() { fun test(x: X) { val interface_as_fun = x.A() - val interface_as_val = x.A + val interface_as_val = x.A val object_as_fun = x.B() - val class_as_val = x.C + val class_as_val = x.C } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt index bff59ebac46..71d617e6796 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt @@ -62,7 +62,7 @@ fun foo( test.ObjectAlias::func test.ObjectSample.Nested::func - test.ObjectAlias.Nested::func + test.ObjectAlias.Nested::func test.EnumSample::Nested test.EnumAlias::Nested @@ -72,4 +72,4 @@ fun foo( test.EnumSample.Nested::func test.EnumAlias.Nested::func -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/call-with-an-explicit-type-receiver/p-3/pos/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/call-with-an-explicit-type-receiver/p-3/pos/2.1.fir.kt index 9c653287c28..42722c95a72 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/call-with-an-explicit-type-receiver/p-3/pos/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver/call-with-an-explicit-type-receiver/p-3/pos/2.1.fir.kt @@ -9,7 +9,7 @@ * ISSUES: KT-39129 */ fun case1() { - C1.V() + C1.V() C1.Companion.V() diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.fir.kt deleted file mode 100644 index 5a7bddd848c..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.fir.kt +++ /dev/null @@ -1,151 +0,0 @@ -// !LANGUAGE: +NewInference -// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION -// SKIP_TXT - -// FILE: TestCase.kt -// TESTCASE NUMBER: 1 -package testsCase1 - -open class A { - operator fun invoke() = print("invoke") -} - -enum class Super_2 { - V1, V2; - - companion object values : A() {} - - private fun case() { - values() - } - - enum class NestedWithCompanion { - V1; - - companion object values : A() {} - - private fun case() { - values() - } - } - - enum class Nested { - V1; - - private fun case() { - values() - } - } -} - -// FILE: TestCase.kt -// TESTCASE NUMBER: 2 -package testsCase2 - -open class A { - operator fun invoke(value: String) = print("invoke $value") -} - -enum class Super_2 { - V1, V2; - - companion object valueOf : A() {} - - private fun case() { - valueOf("") - } - - enum class NestedWithCompanion { - V1; - - companion object valueOf : A() {} - - private fun case() { - valueOf("") - } - } - - enum class Nested { - V1; - - private fun case() { - valueOf("") - } - } -} - - -// FILE: TestCase.kt -// TESTCASE NUMBER: 3 -package testsCase3 - -open class A { - operator fun invoke() = print("invoke") -} - -enum class Super_2 { - V1, V2; - - object values : A() {} - - private fun case() { - values() - } - - enum class NestedWithCompanion { - V1; - - object values : A() {} - - private fun case() { - values() - } - } - - enum class Nested { - V1; - - private fun case() { - values() - } - } -} - -// FILE: TestCase.kt -// TESTCASE NUMBER: 4 -package testsCase4 - -open class A { - operator fun invoke(value: String) = print("invoke $value") -} -open class B { - operator fun invoke(value: String) = print("invoke $value") -} - -enum class Super_2 { - V1, V2; - - object valueOf : A() {} - - private fun case() { - valueOf("") - } - - enum class NestedWithCompanion { - V1; - - object valueOf : B() {} - - private fun case() { - valueOf("") - } - } - - enum class Nested { - V1; - - private fun case() { - valueOf("") - } - } -} diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.kt index 55dd0b6e4c6..ff5e15ae057 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/receivers/p-5/pos/3.1.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +NewInference // !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION // SKIP_TXT