diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 676de7d3868..7cbe7640626 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -46441,6 +46441,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt"); } + @Test + @TestMetadata("companionVsStaticScope.kt") + public void testCompanionVsStaticScope() { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt"); + } + @Test @TestMetadata("constructorCase.kt") public void testConstructorCase() { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index 710bc475510..219e27269a4 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -46441,6 +46441,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt"); } + @Test + @TestMetadata("companionVsStaticScope.kt") + public void testCompanionVsStaticScope() { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt"); + } + @Test @TestMetadata("constructorCase.kt") public void testConstructorCase() { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index c7021f497d2..fe320f6bb9b 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -44071,6 +44071,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt"); } + @Test + @TestMetadata("companionVsStaticScope.kt") + public void testCompanionVsStaticScope() { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt"); + } + @Test @TestMetadata("constructorCase.kt") public void testConstructorCase() { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 16cdb9ea250..1478765c1c1 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -44209,6 +44209,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt"); } + @Test + @TestMetadata("companionVsStaticScope.kt") + public void testCompanionVsStaticScope() { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt"); + } + @Test @TestMetadata("constructorCase.kt") public void testConstructorCase() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.fir.txt new file mode 100644 index 00000000000..fe5308976fb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.fir.txt @@ -0,0 +1,40 @@ +FILE: companionVsStaticScope.kt + public final class Foo : R|kotlin/Any| { + public constructor(): R|Foo| { + super() + } + + public final object Bar : R|kotlin/Any| { + private constructor(): R|Foo.Bar| { + super() + } + + public open override fun toString(): R|kotlin/String| { + ^toString String(object Bar) + } + + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|Foo.Companion| { + super() + } + + public final val Bar: R|kotlin/Int| = Int(10) + public get(): R|kotlin/Int| + + } + + } + public final fun take(it: R|T|): R|T| { + ^take R|/it| + } + public final val x: R|Foo.Bar| = Q|Foo.Bar| + public get(): R|Foo.Bar| + public final val y: R|Foo.Bar| = R|/take|(Q|Foo.Bar|) + public get(): R|Foo.Bar| + public final val z: R|Foo.Bar| = Q|Foo.Bar|.R|kotlin/let|( = let@fun (it: R|Foo.Bar|): R|Foo.Bar| { + ^ R|/it| + } + ) + public get(): R|Foo.Bar| diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt new file mode 100644 index 00000000000..8741db7c39e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt @@ -0,0 +1,20 @@ +// FIR_IDENTICAL +// ISSUE: KT-62866 +// WITH_STDLIB +// FIR_DUMP + +class Foo { + object Bar { + override fun toString(): String = "object Bar" + } + + companion object { + val Bar = 10 + } +} + +fun take(it: T): T = it + +val x = Foo.Bar // K1: val Bar, K2: object Bar +val y = take(Foo.Bar) // K1: val Bar, K2: object Bar +val z = Foo.Bar.let { it } // K1 & K2: object Bar diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.txt new file mode 100644 index 00000000000..1552d5ffbb7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.txt @@ -0,0 +1,28 @@ +package + +public val x: kotlin.Int = 10 +public val y: kotlin.Int +public val z: Foo.Bar +public fun take(/*0*/ it: T): T + +public final class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public object Bar { + private constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ fun toString(): kotlin.String + } + + public companion object Companion { + private constructor Companion() + public final val Bar: kotlin.Int = 10 + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 6117a500c3b..671159c0002 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -46499,6 +46499,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt"); } + @Test + @TestMetadata("companionVsStaticScope.kt") + public void testCompanionVsStaticScope() { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/companionVsStaticScope.kt"); + } + @Test @TestMetadata("constructorCase.kt") public void testConstructorCase() {