added info about smart casts to diagnostic tests

This commit is contained in:
Svetlana Isakova
2013-12-06 20:12:41 +04:00
parent 00da5fe1fb
commit c30259dfbe
116 changed files with 383 additions and 348 deletions
@@ -14,7 +14,7 @@ class B {
fun test() {
if (A.x != null) {
useInt(A.x)
useInt(<!DEBUG_INFO_AUTOCAST!>A.x<!>)
useInt(<!TYPE_MISMATCH!>B.x<!>)
}
}
@@ -3,5 +3,5 @@ package aaa
fun bar(<!UNUSED_PARAMETER!>a<!>: Int, <!UNUSED_PARAMETER!>b<!>: Int) {}
fun foo(a: Int?) {
bar(a!!, a)
bar(a!!, <!DEBUG_INFO_AUTOCAST!>a<!>)
}
@@ -3,5 +3,5 @@ package a
fun <T> foo(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u
fun test(s: String?) {
val <!UNUSED_VARIABLE!>r<!>: String = foo(s!!, s)
val <!UNUSED_VARIABLE!>r<!>: String = foo(s!!, <!DEBUG_INFO_AUTOCAST!>s<!>)
}
@@ -45,7 +45,7 @@ fun testErrorMessages(a: A, ml: MutableList<String>) {
fun rr(s: String?) {
if (s != null) {
val l = arrayListOf("", s)
val l = arrayListOf("", <!DEBUG_INFO_AUTOCAST!>s<!>)
l: MutableList<String>
<!TYPE_MISMATCH!>l<!>: MutableList<String?>
}
@@ -6,9 +6,9 @@ import java.util.HashMap
fun foo(map: MutableMap<Int, String>, value: String?) {
if (value != null) {
map.put(1, value) //ok
map.set(1, value) //type inference failed
map[1] = value //type inference failed
map.put(1, <!DEBUG_INFO_AUTOCAST!>value<!>) //ok
map.set(1, <!DEBUG_INFO_AUTOCAST!>value<!>) //type inference failed
map[1] = <!DEBUG_INFO_AUTOCAST!>value<!> //type inference failed
}
}
@@ -26,7 +26,7 @@ public data open class Tag(public var tagName: String) {
}
else {
attributes["id"] = value<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
attributes["id"] = value
attributes["id"] = <!DEBUG_INFO_AUTOCAST!>value<!>
}
}
}
@@ -5,7 +5,7 @@ class C<T>(t :T)
fun test1(a: Any) {
if (a is String) {
val <!UNUSED_VARIABLE!>c<!>: C<String> = C(a)
val <!UNUSED_VARIABLE!>c<!>: C<String> = C(<!DEBUG_INFO_AUTOCAST!>a<!>)
}
}
@@ -14,6 +14,6 @@ fun f<T>(t :T): C<T> = C(t)
fun test2(a: Any) {
if (a is String) {
val <!UNUSED_VARIABLE!>c1<!>: C<String> = f(a)
val <!UNUSED_VARIABLE!>c1<!>: C<String> = f(<!DEBUG_INFO_AUTOCAST!>a<!>)
}
}
@@ -4,9 +4,9 @@ package a
fun main(args: Array<String>) {
val value: String? = ""
if (value != null) {
foo(Pair("val", value))
foo(Pair("val", <!DEBUG_INFO_AUTOCAST!>value<!>))
foo(Pair("val", value<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>))
foo(Pair<String, String>("val", value))
foo(Pair<String, String>("val", <!DEBUG_INFO_AUTOCAST!>value<!>))
}
}
@@ -7,8 +7,8 @@ class Sub(str : String) : Super(str) {}
fun foo(sup : Super, sub : Sub) {
if (sup is Sub) {
println("${sup.property}")
println(sup.property)
println("${<!DEBUG_INFO_AUTOCAST!>sup<!>.property}")
println(<!DEBUG_INFO_AUTOCAST!>sup<!>.property)
}
println("${sub.property}")
println(sub.property)
@@ -12,10 +12,10 @@ class Test {
useInt(<!TYPE_MISMATCH!>foo<!>)
}
if (this.foo != null) {
useInt(foo)
useInt(<!DEBUG_INFO_AUTOCAST!>foo<!>)
}
if (foo != null) {
useInt(this.foo)
useInt(<!DEBUG_INFO_AUTOCAST!>this.foo<!>)
}
}
@@ -3,15 +3,15 @@ package foo
class A(val i: Int?) {
fun test1() {
if (this@A.i != null) {
useInt(this.i)
useInt(i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.i<!>)
useInt(<!DEBUG_INFO_AUTOCAST!>i<!>)
}
}
inner class B {
fun test2() {
if (i != null) {
useInt(this@A.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this@A.i<!>)
}
}
}
@@ -19,15 +19,15 @@ class A(val i: Int?) {
fun A.foo() {
if (this@foo.i != null) {
useInt(this.i)
useInt(i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.i<!>)
useInt(<!DEBUG_INFO_AUTOCAST!>i<!>)
}
}
fun test3() {
useFunction {
if(i != null) {
useInt(this.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.i<!>)
}
}
}
@@ -5,15 +5,15 @@ class C(val i: Int?) {}
class A(val c: C) {
fun test1() {
if (this@A.c.i != null) {
useInt(this.c.i)
useInt(c.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.c.i<!>)
useInt(<!DEBUG_INFO_AUTOCAST!>c.i<!>)
}
}
inner class B {
fun test2() {
if (c.i != null) {
useInt(this@A.c.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this@A.c.i<!>)
}
}
}
@@ -21,15 +21,15 @@ class A(val c: C) {
fun A.foo() {
if (this@foo.c.i != null) {
useInt(this.c.i)
useInt(c.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.c.i<!>)
useInt(<!DEBUG_INFO_AUTOCAST!>c.i<!>)
}
}
fun test3() {
useFunction {
if(c.i != null) {
useInt(this.c.i)
useInt(<!DEBUG_INFO_AUTOCAST!>this.c.i<!>)
}
}
}