K2: add test for KT-56520, case (4), callable references (bound)

In this test, things work in the similar way as in constructors case (2).
K1 resolves the explicit receiver HashMap<String, String>()
to kotlin.collections.HashMap /* = java.util.HashMap */.
K2 does the similar, but fun processConstructors from ConstructorProcessing.kt
makes a type alias substitution, so in fact constructor of expanded
java.util.HashMap is processed.

Pay attention that both frontends ignore some.HashMap and java.util.HashMap
due to ambiguous classifiers in explicit star importing scope.
See FirScope.processConstructorsByName in ConstructorProcessing.kt
This commit is contained in:
Mikhail Glukhikh
2023-10-30 11:23:36 +01:00
committed by Space Team
parent 168717b811
commit f0058ee0d8
7 changed files with 54 additions and 0 deletions
@@ -44761,6 +44761,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("callableReferenceCase.kt")
public void testCallableReferenceCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt");
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
@@ -44761,6 +44761,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("callableReferenceCase.kt")
public void testCallableReferenceCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt");
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
@@ -42639,6 +42639,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("callableReferenceCase.kt")
public void testCallableReferenceCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt");
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
@@ -42759,6 +42759,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("callableReferenceCase.kt")
public void testCallableReferenceCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt");
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
@@ -0,0 +1,4 @@
FILE: test.kt
public final fun test(): R|kotlin/reflect/KProperty0<kotlin/Int>| {
^test R|java/util/HashMap.HashMap|<R|kotlin/String|, R|kotlin/String|>()::R|SubstitutionOverride<java/util/HashMap.size: R|kotlin/Int|>|
}
@@ -0,0 +1,20 @@
// FIR_IDENTICAL
// ISSUE: KT-56520 (case 4, bound)
// 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 & K2 resolve this to kotlin.collections.HashMap.
HashMap<String, String>()::size
@@ -44819,6 +44819,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("callableReferenceCase.kt")
public void testCallableReferenceCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt");
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {