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
@@ -18,5 +18,5 @@ class OtherContainer<K>(val k: K) {
fun test2() {
val other: OtherContainer<String>? = null
// Error
for (s in <!ITERATOR_ON_NULLABLE!>other<!>) {}
for (s in <!NI;ITERATOR_MISSING, OI;ITERATOR_ON_NULLABLE!>other<!>) {}
}
@@ -9,7 +9,7 @@ class None<T> : Option<T>
fun <T> bind(r: Option<T>): Option<T> {
return if (r is Some) {
// Ideally we should infer Option<T> here (see KT-10896)
(<!TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT!>if<!> (true) <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>None()<!> else <!DEBUG_INFO_SMARTCAST!>r<!>) checkType { <!TYPE_MISMATCH!>_<!><Option<T>>() }
(<!OI;TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT!>if<!> (true) <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>None()<!> else <!DEBUG_INFO_SMARTCAST!>r<!>) checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH!>_<!><Option<T>>() }
// Works correctly
if (true) None() else r
}
@@ -25,10 +25,10 @@ fun <T> bind2(r: Option<T>): Option<T> {
}
fun <T, R> bind3(r: Option<T>): Option<T> {
return if (r is Some) {
return if (r is Some) <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>{
// Diagnoses an error correctly
if (true) <!TYPE_MISMATCH!>None<R>()<!> else r
}
if (true) <!OI;TYPE_MISMATCH!>None<R>()<!> else r
}<!>
else r
}
@@ -1,7 +1,7 @@
// !WITH_NEW_INFERENCE
val test1 = { if (true) <!IMPLICIT_CAST_TO_ANY!>1<!> else <!IMPLICIT_CAST_TO_ANY!>""<!> }
val test1 = { if (true) <!OI;IMPLICIT_CAST_TO_ANY!>1<!> else <!OI;IMPLICIT_CAST_TO_ANY!>""<!> }
val test2 = { { if (true) <!IMPLICIT_CAST_TO_ANY!>1<!> else <!IMPLICIT_CAST_TO_ANY!>""<!> } }
val test2 = { { if (true) <!OI;IMPLICIT_CAST_TO_ANY!>1<!> else <!OI;IMPLICIT_CAST_TO_ANY!>""<!> } }
val test3: (Boolean) -> Any = { if (it) 1 else "" }
@@ -17,8 +17,8 @@ fun testResultOfLambda2() =
fun testResultOfAnonFun1() =
run(fun () =
if (true) <!IMPLICIT_CAST_TO_ANY!>42<!>
else <!IMPLICIT_CAST_TO_ANY!>println()<!>
if (true) <!OI;IMPLICIT_CAST_TO_ANY!>42<!>
else <!OI;IMPLICIT_CAST_TO_ANY!>println()<!>
)
fun testResultOfAnonFun2() =
@@ -28,7 +28,7 @@ fun testResultOfAnonFun2() =
fun testReturnFromAnonFun() =
run(fun () {
return if (true) <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> else println()
return <!NI;TYPE_MISMATCH!>if (true) <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> else println()<!>
})
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>testReturn1<!>() =
@@ -20,10 +20,10 @@ val xx6 = null ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
val xx7 = "" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
val wxx1 = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
val wxx2: Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }
val wxx2: Unit = <!NI;TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }<!>
val wxx3 = idAny(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
val wxx4 = id(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
val wxx5 = idUnit(<!NO_ELSE_IN_WHEN!>when<!> { true -> <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> })
val wxx5 = idUnit(<!NI;TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }<!>)
val wxx6 = null ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
val wxx7 = "" + <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
@@ -51,8 +51,8 @@ fun g1() = <!NO_ELSE_IN_WHEN!>when<!> { true -> work() }
fun g2() = <!NO_ELSE_IN_WHEN!>when<!> { true -> mlist.add() }
fun g3() = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
fun g4(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> work() }
fun g5(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> <!TYPE_MISMATCH!>mlist.add()<!> }
fun g6(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }
fun g5(): Unit = <!NI;TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> <!OI;TYPE_MISMATCH!>mlist.add()<!> }<!>
fun g6(): Unit = <!NI;TYPE_MISMATCH!><!NO_ELSE_IN_WHEN!>when<!> { true -> <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }<!>
fun foo1(x: String?) {
"" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
@@ -30,5 +30,5 @@ fun example() {
return <!TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (true) true<!>
}
return if (true) <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!> else {}
return <!NI;TYPE_MISMATCH!>if (true) <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!> else {}<!>
}
@@ -5,7 +5,7 @@ package kt1075
fun foo(b: String) {
if (<!TYPE_MISMATCH!>b<!> in 1..10) {} //type mismatch
when (b) {
when (<!NI;TYPE_MISMATCH!>b<!>) {
<!TYPE_MISMATCH_IN_RANGE!>in<!> 1..10 -> <!UNUSED_EXPRESSION!>1<!> //no type mismatch, but it should be here
else -> <!UNUSED_EXPRESSION!>2<!>
}
@@ -4,9 +4,9 @@ package f
fun test(a: Boolean, b: Boolean): Int {
return if(a) {
1
} else {
<!TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (b) {
} else <!NI;TYPE_MISMATCH!>{
<!OI;TYPE_MISMATCH!><!INVALID_IF_AS_EXPRESSION!>if<!> (b) {
3
}<!>
}
}<!>
}
@@ -27,7 +27,7 @@ fun foo() {
z = 34
}
}
val <!UNUSED_VARIABLE!>f<!>: ()-> Int = <!TYPE_MISMATCH!>r<!>
val <!UNUSED_VARIABLE!>f<!>: ()-> Int = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>r<!>
val <!UNUSED_VARIABLE!>g<!>: ()-> Any = r
}
@@ -80,7 +80,7 @@ fun testCoercionToUnit() {
45
}
}
val <!UNUSED_VARIABLE!>f<!> : () -> String = <!TYPE_MISMATCH!>checkType<!>
val <!UNUSED_VARIABLE!>f<!> : () -> String = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>checkType<!>
}
fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {}
@@ -107,12 +107,12 @@ fun testImplicitCoercion() {
val <!UNUSED_VARIABLE!>g<!> = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 4
val <!UNUSED_VARIABLE!>h<!> = if (false) <!IMPLICIT_CAST_TO_ANY!>4<!> else <!IMPLICIT_CAST_TO_ANY!>{}<!>
bar(if (true) {
bar(<!NI;TYPE_MISMATCH!>if (true) {
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>4<!>
}
else {
<!UNUSED_VALUE!>z =<!> 342
})
}<!>)
}
fun fooWithAnyArg(<!UNUSED_PARAMETER!>arg<!>: Any) {}
@@ -9,8 +9,8 @@ fun test() {
// KT-KT-9070
<!TYPE_MISMATCH!>{ }<!> <!USELESS_ELVIS!>?: 1<!>
use({ 2 } <!USELESS_ELVIS_ON_LAMBDA_EXPRESSION!>?:<!> 1);
use(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>{ 2 }<!> <!USELESS_ELVIS_ON_LAMBDA_EXPRESSION!>?:<!> 1);
1 <!USELESS_ELVIS!>?: <!TYPE_MISMATCH, UNUSED_LAMBDA_EXPRESSION!>{ }<!><!>
use(1 <!USELESS_ELVIS!>?: { }<!>)
use(1 <!USELESS_ELVIS!>?: <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>{ }<!><!>)
}
@@ -12,7 +12,7 @@ public class J {
val testImplicitExclExcl1: String = J.s
val testImplicitExclExcl2: String? = J.s
val testImplicitExclExcl3: String = <!TYPE_MISMATCH!>J.m[""]<!>
val testImplicitExclExcl3: String = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>J.m[""]<!>
val testImplicitExclExcl4: String? = J.m[""]
val testExclExcl1: String = J.s!!
@@ -30,7 +30,7 @@ val testSafeCall4: String? = J.m[""]?.let { it.toString() }
val testIf1: String = if (true) J.s else J.s
val testIf2: String? = if (true) J.s else J.s
val testIf3: String = if (true) <!TYPE_MISMATCH!>J.m[""]<!> else <!TYPE_MISMATCH!>J.m[""]<!>
val testIf3: String = if (true) <!TYPE_MISMATCH!>J.m[""]<!> else <!OI;TYPE_MISMATCH!>J.m[""]<!>
val testIf4: String? = if (true) J.m[""] else J.m[""]
val testWhen1: String = when { else -> J.s }
@@ -15,7 +15,7 @@ fun foo() : Int {
fun bar() : Int =
try {
<!TYPE_MISMATCH!>doSmth()<!>
<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>doSmth()<!>
}
catch (e: Exception) {
<!TYPE_MISMATCH!>""<!>
@@ -13,9 +13,9 @@ fun <T: Any> exclExcl(t: T?): T = t!!
fun test11() {
// not 'String!'
exclExcl(A.foo()) checkType { _<String>() }
exclExcl(A.foo()) checkType { <!TYPE_MISMATCH!>_<!><String?>() }
exclExcl(A.foo()) checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH!>_<!><String?>() }
// not 'String!'
A.foo()!! checkType { _<String>() }
A.foo()!! checkType { <!TYPE_MISMATCH!>_<!><String?>() }
A.foo()!! checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER, OI;TYPE_MISMATCH!>_<!><String?>() }
}
@@ -1,7 +1,7 @@
// !WITH_NEW_INFERENCE
val test1 = { when (true) { true -> <!IMPLICIT_CAST_TO_ANY!>1<!>; else -> <!IMPLICIT_CAST_TO_ANY!>""<!> } }
val test1 = { when (true) { true -> <!OI;IMPLICIT_CAST_TO_ANY!>1<!>; else -> <!OI;IMPLICIT_CAST_TO_ANY!>""<!> } }
val test2 = { { when (true) { true -> <!IMPLICIT_CAST_TO_ANY!>1<!>; else -> <!IMPLICIT_CAST_TO_ANY!>""<!> } } }
val test2 = { { when (true) { true -> <!OI;IMPLICIT_CAST_TO_ANY!>1<!>; else -> <!OI;IMPLICIT_CAST_TO_ANY!>""<!> } } }
val test3: (Boolean) -> Any = { when (true) { true -> 1; else -> "" } }