K2: add test for KT-56520, case (2), constructors, Space subcase
In this test, both frontends resolve to fun Semaphore. Both work this way because interface/class Semaphore classifiers are clashed (ambiguity) and ignored. K2 reports ambiguity for some similar cases, but constructor resolve still ignores ambiguous classifiers when found. (see FirScope.processConstructorsByName in ConstructorProcessing.kt)
This commit is contained in:
committed by
Space Team
parent
6049f8657b
commit
d07f3a14e6
+6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCase.fir.kt
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// ISSUE: KT-56520 (case 2)
|
||||
// FIR_DUMP
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: some/HashMap.java
|
||||
|
||||
package some;
|
||||
|
||||
public class HashMap<K, V> extends java.util.HashMap<K, V> {}
|
||||
|
||||
// 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
|
||||
<!DEBUG_INFO_CALL("fqName: java.util.HashMap.HashMap; typeCall: function")!>HashMap<String, String>()<!>
|
||||
Vendored
+1
-2
@@ -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<String, String>()
|
||||
<!DEBUG_INFO_CALL("fqName: kotlin.collections.HashMap.<init>; typeCall: function")!>HashMap<String, String>()<!>
|
||||
|
||||
+12
@@ -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))
|
||||
}
|
||||
+29
@@ -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
|
||||
<!DEBUG_INFO_CALL("fqName: kotlinx.coroutines.sync.Semaphore; typeCall: function")!>Semaphore(1)<!>
|
||||
+36
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user