From 0f53ee64d6db2b7057b993e41ddcf6cb56e13330 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 5 Mar 2024 11:42:15 +0100 Subject: [PATCH] K2: make qualifier & classifier the same tower level #KT-65789 Fixed #KT-38031 Fixed --- .../resolve/problems/javaQualifier.fir.txt | 2 +- .../testData/resolve/problems/javaQualifier.kt | 4 +++- .../fir/resolve/calls/tower/FirTowerResolveTask.kt | 4 ++-- .../kotlin/fir/resolve/calls/tower/TowerGroup.kt | 8 ++------ .../constructorVsSyntheticValues.fir.kt | 4 ++-- .../constructorVsSyntheticValues.fir.txt | 8 ++++---- .../constructorVsSyntheticValuesPrioritized.fir.kt | 14 ++++++++++++++ ...constructorVsSyntheticValuesPrioritized.fir.txt | 6 +++--- .../constructorVsSyntheticValuesPrioritized.kt | 1 - .../constructorVsTopLevel.fir.txt | 4 ++-- 10 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.fir.txt index 1301cc1c5e2..aa6eabf0fff 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.fir.txt @@ -1,6 +1,6 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - Q|W|.R|/W.E*s|().R|kotlin/String.length| + Q|W|.#().# Q|W.E|.# Q|W.E|.R|/W.E.w*s| } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt b/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt index 23f029c7c80..d124b8c3ec2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/javaQualifier.kt @@ -1,3 +1,5 @@ +// ISSUE: KT-38031 + // FILE: W.java public class W { public static class E { @@ -11,7 +13,7 @@ public class W { // FILE: main.kt fun main() { - W.E().length // ambiguity in old FE, resolved to static method in FIR + W.E().length // ambiguity in both FIR / old FE W.E.length // resolved with error to the class W.E in FIR and old FE W.E.w // resolved to static field W.e.W in FE } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt index c23d79bde97..adc76a9c941 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt @@ -269,7 +269,7 @@ internal open class FirTowerResolveTask( else -> null } ), - info, TowerGroup.Qualifier + info, TowerGroup.QualifierOrClassifier ) } @@ -284,7 +284,7 @@ internal open class FirTowerResolveTask( val scope = qualifierReceiver.classifierScope() ?: return processLevel( scope.toScopeTowerLevel(constructorFilter = ConstructorFilter.OnlyNested), info, - TowerGroup.Classifier + TowerGroup.QualifierOrClassifier ) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt index 3ad648e3977..ef53c70e066 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt @@ -29,9 +29,7 @@ sealed class TowerGroupKind(val index: Byte) : Comparable { data object Start : TowerGroupKind(0b0) - data object Qualifier : TowerGroupKind(1) - - data object Classifier : TowerGroupKind(2) + data object QualifierOrClassifier : TowerGroupKind(1) class TopPrioritized(depth: Int) : WithDepth(3, depth) @@ -176,9 +174,7 @@ private constructor( val Start = kindOf(TowerGroupKind.Start) - val Qualifier = kindOf(TowerGroupKind.Qualifier) - - val Classifier = kindOf(TowerGroupKind.Classifier) + val QualifierOrClassifier = kindOf(TowerGroupKind.QualifierOrClassifier) val QualifierValue = kindOf(TowerGroupKind.QualifierValue) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt index 1c557ac075c..4da76a6412e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt @@ -13,7 +13,7 @@ enum class SomeClass { } } -val resultValues = SomeClass.values() -val resultValuesRef = SomeClass::values +val resultValues = SomeClass.values() +val resultValuesRef = SomeClass::values val resultEntries = SomeClass.entries val resultEntriesRef = SomeClass::entries diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt index 2b0603f1107..9f2b9c4cf2d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt @@ -44,10 +44,10 @@ FILE: constructorVsSyntheticValues.fir.kt public get(): R|kotlin/enums/EnumEntries| } - public final val resultValues: R|kotlin/Array| = Q|SomeClass|.R|/SomeClass.values*s|() - public get(): R|kotlin/Array| - public final val resultValuesRef: R|kotlin/reflect/KFunction0>| = Q|SomeClass|::R|/SomeClass.values*s| - public get(): R|kotlin/reflect/KFunction0>| + public final val resultValues: = Q|SomeClass|.#() + public get(): + public final val resultValuesRef: = Q|SomeClass|::# + public get(): public final val resultEntries: R|SomeClass.entries.Companion| = Q|SomeClass.entries| public get(): R|SomeClass.entries.Companion| public final val resultEntriesRef: R|kotlin/reflect/KFunction0| = Q|SomeClass|::R|/SomeClass.entries.entries| diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt new file mode 100644 index 00000000000..2449632d7d1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-65789 +// LANGUAGE: +PrioritizedEnumEntries +// FIR_DUMP + +enum class SomeClass { + FIRST, LAST; + + class entries { + companion object + } +} + +val resultEntries = SomeClass.entries +val resultEntriesRef = SomeClass::entries diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.txt index e04909f1c32..17216809603 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.txt @@ -1,4 +1,4 @@ -FILE: constructorVsSyntheticValuesPrioritized.kt +FILE: constructorVsSyntheticValuesPrioritized.fir.kt public final enum class SomeClass : R|kotlin/Enum| { private constructor(): R|SomeClass| { super|>() @@ -32,5 +32,5 @@ FILE: constructorVsSyntheticValuesPrioritized.kt } public final val resultEntries: R|kotlin/enums/EnumEntries| = Q|SomeClass|.R|/SomeClass.entries*s| public get(): R|kotlin/enums/EnumEntries| - public final val resultEntriesRef: R|kotlin/reflect/KProperty0>| = Q|SomeClass|::R|/SomeClass.entries*s| - public get(): R|kotlin/reflect/KProperty0>| + public final val resultEntriesRef: = Q|SomeClass|::# + public get(): diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt index 9423d738b66..6936136b6b5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // ISSUE: KT-65789 // LANGUAGE: +PrioritizedEnumEntries // FIR_DUMP diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt index 6ef68434690..859114bd4ed 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt @@ -14,8 +14,8 @@ FILE: Foo.kt } public final val foo: R|bar/Foo| = R|bar/Foo.Foo|(String(1)) public get(): R|bar/Foo| - public final val barFoo: R|kotlin/Unit| = Q|bar|.R|bar/Foo|(String(2)) - public get(): R|kotlin/Unit| + public final val barFoo: R|bar/Foo| = Q|bar|.R|bar/Foo.Foo|(String(2)) + public get(): R|bar/Foo| FILE: another.kt package foo