Add test for KT-55931

This commit is contained in:
Denis.Zharkov
2023-01-13 16:34:20 +01:00
committed by Space Team
parent d18672bfb1
commit a37e3def14
6 changed files with 110 additions and 0 deletions
@@ -14904,6 +14904,22 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/callableReferences")
@TestDataPath("$PROJECT_ROOT")
public class CallableReferences {
@Test
public void testAllFilesPresentInCallableReferences() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/callableReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("kt55931.kt")
public void testKt55931() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/callableReferences/kt55931.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
@TestDataPath("$PROJECT_ROOT")
@@ -14910,6 +14910,22 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/callableReferences")
@TestDataPath("$PROJECT_ROOT")
public class CallableReferences {
@Test
public void testAllFilesPresentInCallableReferences() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/callableReferences"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("kt55931.kt")
public void testKt55931() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/callableReferences/kt55931.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
@TestDataPath("$PROJECT_ROOT")
@@ -14904,6 +14904,22 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/callableReferences")
@TestDataPath("$PROJECT_ROOT")
public class CallableReferences {
@Test
public void testAllFilesPresentInCallableReferences() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/callableReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("kt55931.kt")
public void testKt55931() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/callableReferences/kt55931.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,23 @@
// ISSUE: KT-55931
// SKIP_TXT
fun fun1() {}
fun fun2() {}
fun takeLambda(lambda: () -> Unit) = lambda()
fun foo(b: Boolean) {
val x1 = if (b) { ::fun1 } else { ::fun2 } // OK
takeLambda {
val x2 = if (b) ::fun1 else ::fun2 // OK
// NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER and DEBUG_UNRESOLVED on both callable references
// Since 1.4.0 (NI)
val x3 = if (b) { ::fun1 } else { ::fun2 }
}
val w: () -> Unit = {
val x4 = if (b) ::fun1 else ::fun2 // OK
// OK, too
val x5 = if (b) { ::fun1 } else { ::fun2 }
}
}
@@ -0,0 +1,23 @@
// ISSUE: KT-55931
// SKIP_TXT
fun fun1() {}
fun fun2() {}
fun takeLambda(lambda: () -> Unit) = lambda()
fun foo(b: Boolean) {
val x1 = if (b) { ::fun1 } else { ::fun2 } // OK
takeLambda {
val x2 = if (b) ::fun1 else ::fun2 // OK
// NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER and DEBUG_UNRESOLVED on both callable references
// Since 1.4.0 (NI)
val x3 = if (b) { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>fun1<!><!> } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::<!DEBUG_INFO_MISSING_UNRESOLVED!>fun2<!><!> }
}
val w: () -> Unit = {
val x4 = if (b) ::fun1 else ::fun2 // OK
// OK, too
val x5 = if (b) { ::fun1 } else { ::fun2 }
}
}
@@ -14910,6 +14910,22 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/callableReferences")
@TestDataPath("$PROJECT_ROOT")
public class CallableReferences {
@Test
public void testAllFilesPresentInCallableReferences() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/callableReferences"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("kt55931.kt")
public void testKt55931() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/callableReferences/kt55931.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
@TestDataPath("$PROJECT_ROOT")