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 09f7ea8ab76..4a350e6f199 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 @@ -44766,6 +44766,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testConstructorCase() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt"); } + + @Test + @TestMetadata("constructorCaseSpace.kt") + public void testConstructorCaseSpace() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); + } } } 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 6e3f67d8ff2..c7e4c8283ff 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 @@ -44766,6 +44766,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testConstructorCase() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt"); } + + @Test + @TestMetadata("constructorCaseSpace.kt") + public void testConstructorCaseSpace() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); + } } } 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 69f5241336d..f4ebe4f624d 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 @@ -42644,6 +42644,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testConstructorCase() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt"); } + + @Test + @TestMetadata("constructorCaseSpace.kt") + public void testConstructorCaseSpace() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); + } } } 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 ae06d8f38b4..e53c10aaf35 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 @@ -42764,6 +42764,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testConstructorCase() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt"); } + + @Test + @TestMetadata("constructorCaseSpace.kt") + public void testConstructorCaseSpace() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); + } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.fir.kt new file mode 100644 index 00000000000..4bd9a830102 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.fir.kt @@ -0,0 +1,20 @@ +// ISSUE: KT-56520 (case 2) +// FIR_DUMP +// FULL_JDK + +// FILE: some/HashMap.java + +package some; + +public class HashMap extends java.util.HashMap {} + +// FILE: test.kt + +import java.util.* +import some.* + +fun test() = + // Ok in both K1 & K2. + // K1 resolves this to kotlin.collections.HashMap. + // K2 resolves this to java.util.HashMap + HashMap() diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt index 067ae3843f5..b1e166f30e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // ISSUE: KT-56520 (case 2) // FIR_DUMP // FULL_JDK @@ -18,4 +17,4 @@ fun test() = // Ok in both K1 & K2. // K1 resolves this to kotlin.collections.HashMap. // K2 resolves this to java.util.HashMap - HashMap() + ; typeCall: function")!>HashMap() diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.fir.txt new file mode 100644 index 00000000000..608eb060186 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.fir.txt @@ -0,0 +1,12 @@ +FILE: 1.kt + package kotlinx.coroutines.sync + + public abstract interface Semaphore : R|kotlin/Any| { + } + public final fun Semaphore(arg0: R|kotlin/Int|, arg: R|kotlin/Int| = Int(0)): R|kotlin/Int| { + ^Semaphore Int(1) + } +FILE: test.kt + public final fun test(): R|kotlin/Int| { + ^test R|kotlinx/coroutines/sync/Semaphore|(Int(1)) + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt new file mode 100644 index 00000000000..bf9a7370121 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt @@ -0,0 +1,29 @@ +// FIR_IDENTICAL + +// ISSUE: KT-56520 (case 2, Space subcase) +// FIR_DUMP +// FULL_JDK + +// FILE: 1.kt + +package kotlinx.coroutines.sync; + +interface Semaphore {} + +fun Semaphore(arg0: Int, arg: Int = 0) = 1 + +// FILE: 2.java +package java.util.concurrent; + +public class Semaphore { + public Semaphore(arg: Int) {} +} + +// FILE: test.kt +import java.util.concurrent.* +import kotlinx.coroutines.sync.* + +fun test() = + // K1/K2: resolve to kotlinx.coroutines.sync.Semaphore + // K2 ignores java.util.concurrent because of interface/class classifier ambiguity + Semaphore(1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.txt new file mode 100644 index 00000000000..9cb569d0f7c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.txt @@ -0,0 +1,36 @@ +package + +public fun test(): kotlin.Int + +package java { + + package java.util { + + package java.util.concurrent { + + public open class Semaphore { + public constructor Semaphore() + 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 + } + } + } +} + +package kotlinx { + + package kotlinx.coroutines { + + package kotlinx.coroutines.sync { + public fun Semaphore(/*0*/ arg0: kotlin.Int, /*1*/ arg: kotlin.Int = ...): kotlin.Int + + public interface Semaphore { + 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 edcda2a2bb3..a425b42eecd 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 @@ -44824,6 +44824,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testConstructorCase() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.kt"); } + + @Test + @TestMetadata("constructorCaseSpace.kt") + public void testConstructorCaseSpace() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); + } } }