deprecating types after colon

This commit is contained in:
Dmitry Jemerov
2015-04-21 18:32:31 +02:00
parent b7a4b3c17d
commit f374eec8f1
268 changed files with 1055 additions and 769 deletions
@@ -1,3 +1,5 @@
// !CHECK_TYPE
package a
fun <T> id(t: T): T = t
@@ -15,17 +17,17 @@ fun test(a: A, b: B, c: C) {
val d: C = id(<!DEBUG_INFO_SMARTCAST!>a<!>)
val e: Any = id(a)
val f = id(a)
f: A
checkSubtype<A>(f)
val g = two(<!DEBUG_INFO_SMARTCAST!>a<!>, b)
g: B
g: A
checkSubtype<B>(g)
checkSubtype<A>(g)
// smart cast isn't needed, but is reported due to KT-4294
val h: Any = two(<!DEBUG_INFO_SMARTCAST!>a<!>, b)
val k = three(a, b, c)
k: A
<!TYPE_MISMATCH!>k<!>: B
checkSubtype<A>(k)
checkSubtype<B>(<!TYPE_MISMATCH!>k<!>)
val l: Int = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>three<!>(a, b, c)
use(d, e, f, g, h, k, l)
@@ -47,8 +49,8 @@ fun testErrorMessages(a: A, ml: MutableList<String>) {
fun rr(s: String?) {
if (s != null) {
val l = arrayListOf("", <!DEBUG_INFO_SMARTCAST!>s<!>)
l: MutableList<String>
<!TYPE_MISMATCH!>l<!>: MutableList<String?>
checkSubtype<MutableList<String>>(l)
checkSubtype<MutableList<String?>>(<!TYPE_MISMATCH!>l<!>)
}
}
@@ -1,7 +1,7 @@
//KT-5455 Need warning about redundant type cast
fun foo(o: Any): Int {
if (o is String) {
return (o <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as String<!>).length()
return (o <!USELESS_CAST!>as String<!>).length()
}
return -1
}
@@ -13,16 +13,16 @@ class B: A()
fun test(a: Any?) {
if (a is B) {
(a <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as A<!>).foo()
(a <!USELESS_CAST!>as A<!>).foo()
}
}
fun test1(a: B) {
(a <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as A?<!>)?.foo()
(a <!USELESS_CAST!>as A?<!>)?.foo()
}
fun test2(b: B?) {
if (b != null) {
(b <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as A<!>).foo()
(b <!USELESS_CAST!>as A<!>).foo()
}
}
@@ -1,3 +1,5 @@
// !CHECK_TYPE
public fun foo(x: String?): Int {
var y: Any
loop@ while (true) {
@@ -8,7 +10,7 @@ public fun foo(x: String?): Int {
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
}
// y is always Int after when
<!DEBUG_INFO_SMARTCAST!>y<!>: Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
}
// x is null because of the break
return x<!UNSAFE_CALL!>.<!>length()
@@ -1,3 +1,5 @@
// !CHECK_TYPE
fun bar(): Boolean { return true }
public fun foo(x: String?): Int {
@@ -11,10 +13,10 @@ public fun foo(x: String?): Int {
else -> <!DEBUG_INFO_SMARTCAST!>x<!>.length()
}
// y is always Int after when
<!DEBUG_INFO_SMARTCAST!>y<!>: Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
} while (bar())
// y is always Int even here
<!DEBUG_INFO_SMARTCAST!>y<!>: Int
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>y<!>)
// x is null because of the break
return x<!UNSAFE_CALL!>.<!>length()
}