Highlighting "as Foo" for useless casts in gray.

#KT-6070 fixed
This commit is contained in:
Evgeny Gerashchenko
2014-11-28 21:33:52 +03:00
parent 20ee59c1e5
commit a3fdce8131
34 changed files with 60 additions and 53 deletions
@@ -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_STATIC_ASSERT_IS_FINE!>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_STATIC_ASSERT_IS_FINE!>as A<!>).foo()
}
}
fun test1(a: B) {
(a <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> A?)?.foo()
(a <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as A?<!>)?.foo()
}
fun test2(b: B?) {
if (b != null) {
(b <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> A).foo()
(b <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as A<!>).foo()
}
}