KT-5455 Need warning about redundant type cast

#KT-5455 Fixed
This commit is contained in:
Svetlana Isakova
2014-10-03 19:33:42 +04:00
parent b20327770b
commit a47729c626
13 changed files with 139 additions and 33 deletions
@@ -0,0 +1,28 @@
//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 -1
}
open class A {
fun foo() {}
}
class B: A()
fun test(a: Any?) {
if (a is B) {
(a <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> A).foo()
}
}
fun test1(a: B) {
(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()
}
}