Add diagnostics to test data from NI

This commit is contained in:
Mikhail Zarechenskiy
2017-11-22 08:50:30 +03:00
parent a71238bf94
commit 8757298994
480 changed files with 1136 additions and 1120 deletions
@@ -2,13 +2,13 @@
// !DIAGNOSTICS: -USELESS_ELVIS
fun test() {
bar(if (true) {
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>
bar(<!NI;TYPE_MISMATCH!>if (true) {
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>
} else {
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
})
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
}<!>)
bar(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>)
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
}
fun bar(s: String) = s
@@ -14,7 +14,7 @@ fun testElvis(a: Int?, b: Int?) {
if (a != null) {
doInt(b ?: <!DEBUG_INFO_SMARTCAST!>a<!>)
}
doList(getList() ?: <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyListOfA<!>()) //should be an error
doList(getList() ?: <!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyListOfA<!>()) //should be an error
doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed
}
@@ -23,15 +23,15 @@ fun testDataFlowInfo1(a: Int?, b: Int?) {
val c: Int = a ?: b!!
doInt(c)
// b is nullable if a != null
b <!UNSAFE_OPERATOR_CALL!>+<!> 1
b <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;UNSAFE_OPERATOR_CALL!>+<!> 1
}
fun testDataFlowInfo2(a: Int?, b: Int?) {
doInt(a ?: b!!)
// b is nullable if a != null
b <!UNSAFE_OPERATOR_CALL!>+<!> 1
b <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;UNSAFE_OPERATOR_CALL!>+<!> 1
}
fun testTypeMismatch(a: String?, b: Any) {
doInt(<!TYPE_MISMATCH!>a<!> ?: <!TYPE_MISMATCH!>b<!>)
doInt(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>a<!> ?: <!OI;TYPE_MISMATCH!>b<!><!>)
}
@@ -13,8 +13,8 @@ fun <T: A> emptyNullableListOfA(): List<T>? = null
//-------------------------------
fun testExclExcl() {
doList(<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyNullableListOfA<!>()!!) //should be an error here
val <!UNUSED_VARIABLE!>l<!>: List<Int> = id(<!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyNullableListOfA<!>()!!)
doList(<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyNullableListOfA<!>()!!) //should be an error here
val <!UNUSED_VARIABLE!>l<!>: List<Int> = id(<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>emptyNullableListOfA<!>()!!)
doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase)
}
@@ -9,7 +9,7 @@ interface D: A, B
interface E: A, B
fun foo(c: C?, d: D?, e: E?) {
val test1: A? = <!TYPE_MISMATCH!>c ?: d<!> ?: e
val test1: A? = <!OI;TYPE_MISMATCH!>c ?: d<!> ?: e
val test2: B? = if (false) if (true) c else d else e
@@ -4,25 +4,25 @@ package b
fun bar(i: Int) = i
fun test(a: Int?, b: Int?) {
bar(if (a == null) return else <!TYPE_MISMATCH!>b<!>)
bar(<!NI;TYPE_MISMATCH!>if (a == null) return else <!OI;TYPE_MISMATCH!>b<!><!>)
}
fun test(a: Int?, b: Int?, c: Int?) {
bar(if (a == null) return else if (b == null) return else <!TYPE_MISMATCH!>c<!>)
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) return else if (b == null) return else <!OI;TYPE_MISMATCH!>c<!><!>)
}
fun test(a: Any?, b: Any?, c: Int?) {
bar(if (a == null) if (b == null) <!TYPE_MISMATCH!>c<!> else return else return)
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) if (b == null) <!OI;TYPE_MISMATCH!>c<!> else return else return<!>)
}
fun test(a: Int?, b: Any?, c: Int?) {
bar(if (a == null) {
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (a == null) {
return
} else {
if (b == null) {
return
} else {
<!TYPE_MISMATCH!>c<!>
<!OI;TYPE_MISMATCH!>c<!>
}
})
}<!>)
}