[FIR] Fix "Expected some types" exception, ^KT-51274 Fixed

This commit is contained in:
Ivan Kochurkin
2022-02-15 21:02:34 +03:00
committed by teamcity
parent 6a3b7a9f91
commit 31d9313c51
10 changed files with 54 additions and 5 deletions
@@ -10292,6 +10292,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt");
}
@Test
@TestMetadata("kt24158.kt")
public void testKt24158() throws Exception {
@@ -10292,6 +10292,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt");
}
@Test
@TestMetadata("kt24158.kt")
public void testKt24158() throws Exception {
@@ -10292,6 +10292,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt");
}
@Test
@TestMetadata("kt24158.kt")
public void testKt24158() throws Exception {
@@ -102,9 +102,11 @@ object ConeTypeIntersector {
val iterator = filteredTypes.iterator()
while (iterator.hasNext()) {
val upper = iterator.next()
val shouldFilter = filteredTypes.any { lower -> lower !== upper && predicate(lower, upper) }
if (shouldFilter) iterator.remove()
if (filteredTypes.any { lower -> lower !== upper && predicate(lower, upper) } ||
upper is ConeErrorType && filteredTypes.size > 1
) {
iterator.remove()
}
}
return filteredTypes
}
@@ -0,0 +1,9 @@
// ISSUE: KT-51274
fun test() {
val x = <!UNRESOLVED_REFERENCE!>unresolved<!>()
val y = when (x) {
is String -> x
else -> throw Exception()
}
}
@@ -0,0 +1,9 @@
// ISSUE: KT-51274
fun test() {
val x = <!UNRESOLVED_REFERENCE!>unresolved<!>()
val y = when (<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>) {
is String -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
else -> throw Exception()
}
}
@@ -0,0 +1,3 @@
package
public fun test(): kotlin.Unit
@@ -10298,6 +10298,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt");
}
@Test
@TestMetadata("kt24158.kt")
public void testKt24158() throws Exception {
@@ -184,8 +184,8 @@ fun case_13(x: <!UNRESOLVED_REFERENCE!>otherpackage.Case13<!>?) =
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean")!>if ((x == null !is Boolean) !== true) {
throw Exception()
} else {
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Symbol not found for otherpackage.Case13? & kotlin.Boolean & ERROR CLASS: Symbol not found for otherpackage.Case13?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Symbol not found for otherpackage.Case13? & kotlin.Boolean & ERROR CLASS: Symbol not found for otherpackage.Case13?")!>x<!>.equals(x)
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Symbol not found for otherpackage.Case13? & kotlin.Boolean")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Symbol not found for otherpackage.Case13? & kotlin.Boolean")!>x<!>.equals(x)
}<!>
// TESTCASE NUMBER: 14
@@ -196,6 +196,7 @@ class Case14 {
}
}
@Suppress("UNREACHABLE_CODE")
fun case_14() {
val a = Case14()
@@ -205,6 +205,7 @@ class Case14 {
}
}
@Suppress("UNREACHABLE_CODE")
fun case_14() {
val a = Case14()