[FIR-TEST] Add test with unresolved SAM usage of Comparator

This commit is contained in:
Dmitriy Novozhilov
2019-11-25 13:19:36 +03:00
parent 98af866417
commit 4fc554fa9a
3 changed files with 52 additions and 0 deletions
@@ -0,0 +1,15 @@
fun test_1() {
val comp = <!UNRESOLVED_REFERENCE!>Comparator<!><Int> { x, y -> 1 }
}
fun test_2(list: List<Int>) {
val comp = java.util.<!UNRESOLVED_REFERENCE!>Comparator<!><Int> { x, y -> 1 }
}
fun test_3(comparator: java.util.Comparator<Int>) {
comparator.compare(1, 2)
}
fun test_4(comparator: Comparator<Int>) {
comparator.compare(1, 2)
}
@@ -0,0 +1,19 @@
FILE: unresolvedComparator.kt
public final fun test_1(): R|kotlin/Unit| {
lval comp: <ERROR TYPE REF: Unresolved name: Comparator> = <Unresolved name: Comparator>#<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|class error: No type for parameter|, y: R|class error: No type for parameter|): R|kotlin/Int| {
Int(1)
}
)
}
public final fun test_2(list: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
lval comp: <ERROR TYPE REF: Unresolved name: Comparator> = Q|java/util|.<Unresolved name: Comparator>#<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|class error: No type for parameter|, y: R|class error: No type for parameter|): R|kotlin/Int| {
Int(1)
}
)
}
public final fun test_3(comparator: R|java/util/Comparator<kotlin/Int>|): R|kotlin/Unit| {
R|<local>/comparator|.R|FakeOverride<java/util/Comparator.compare: R|kotlin/Int|>|(Int(1), Int(2))
}
public final fun test_4(comparator: R|kotlin/Comparator<kotlin/Int>|): R|kotlin/Unit| {
R|<local>/comparator|.R|FakeOverride<java/util/Comparator.compare: R|kotlin/Int|>|(Int(1), Int(2))
}
@@ -481,4 +481,22 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.kt"); runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/StaticGenericMethod.kt");
} }
} }
@TestMetadata("compiler/fir/resolve/testData/resolve/stdlib/problems")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Problems extends AbstractFirDiagnosticsWithStdlibTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInProblems() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), true);
}
@TestMetadata("unresolvedComparator.kt")
public void testUnresolvedComparator() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/unresolvedComparator.kt");
}
}
} }