[FIR] KT-58674: Ensure loop conditions have no expected type in K2

This commit is contained in:
Nikolay Lunyak
2023-05-15 11:33:06 +03:00
committed by Space Team
parent a50ae9db9d
commit 737c8c20f6
7 changed files with 72 additions and 0 deletions
@@ -1257,6 +1257,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/Variance.kt");
}
@Test
@TestMetadata("whileConditionExpectedType.kt")
public void testWhileConditionExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/whileConditionExpectedType.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -1257,6 +1257,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/Variance.kt");
}
@Test
@TestMetadata("whileConditionExpectedType.kt")
public void testWhileConditionExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/whileConditionExpectedType.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -1257,6 +1257,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/Variance.kt");
}
@Test
@TestMetadata("whileConditionExpectedType.kt")
public void testWhileConditionExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/whileConditionExpectedType.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -1257,6 +1257,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/Variance.kt");
}
@Test
@TestMetadata("whileConditionExpectedType.kt")
public void testWhileConditionExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/whileConditionExpectedType.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,21 @@
// ISSUE: KT-58674
// INFERENCE_HELPERS
fun test() {
while (<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materialize<!>()) { // K1: OK, K2: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
}
do {
} while (<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materialize<!>()) // K1: OK, K2: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
if (materialize()) {
}
when (val it = materialize<Boolean>()) {
materialize() -> {}
else -> {}
}
}
@@ -0,0 +1,21 @@
// ISSUE: KT-58674
// INFERENCE_HELPERS
fun test() {
while (materialize()) { // K1: OK, K2: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
}
do {
} while (materialize()) // K1: OK, K2: NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER
if (materialize()) {
}
when (val it = materialize<Boolean>()) {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materialize<!>() -> {}
else -> {}
}
}
@@ -1257,6 +1257,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/Variance.kt");
}
@Test
@TestMetadata("whileConditionExpectedType.kt")
public void testWhileConditionExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/whileConditionExpectedType.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/annotations")
@TestDataPath("$PROJECT_ROOT")