FIR: support CONDITION_TYPE_MISMATCH diagnostic

We report CONDITION_TYPE_MISMATCH on
- loop conditions
- when branch conditions
- binary logic arguments
This commit is contained in:
Mikhail Glukhikh
2021-05-18 13:26:27 +03:00
parent e85d97b894
commit 3663884db2
27 changed files with 165 additions and 50 deletions
@@ -26,7 +26,7 @@ import checkSubtype
*/
fun case1() {
val a: Any = true
if (a) { "true" } else "false"
if (<!CONDITION_TYPE_MISMATCH!>a<!>) { "true" } else "false"
<!NONE_APPLICABLE!>checkSubtype<!><Boolean>(a)
}
@@ -37,7 +37,7 @@ fun case1() {
*/
fun case2() {
val a = JavaContainer.aO
if (a) { "true" } else "false"
if (<!CONDITION_TYPE_MISMATCH!>a<!>) { "true" } else "false"
<!NONE_APPLICABLE!>checkSubtype<!><Boolean>(a)
}
@@ -54,7 +54,7 @@ public class JavaClassCase3{
fun case3() {
val x = JavaClassCase3.id(null) // Nothing!
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>x<!>
val a = if (x) {
val a = if (<!CONDITION_TYPE_MISMATCH!>x<!>) {
"NOK"
} else "NOK"
}