[FIR] Fix missing USELESS_CAST

`FirUselessTypeOperationCallChecker` always checks exact types matching for `as` operator

Simplify code of cast checker and utils

^KT-56629 Fixed
^KT-56615 Fixed
^KT-59820 Fixed
This commit is contained in:
Ivan Kochurkin
2023-10-19 20:35:03 +02:00
committed by Space Team
parent 2f8026f335
commit d50c6f1b6d
21 changed files with 209 additions and 121 deletions
+36
View File
@@ -0,0 +1,36 @@
// ISSUE: KT-56629, KT-56615
class Klass
fun foo(arg: Klass) {
arg <!USELESS_CAST!>as Klass<!>
arg <!USELESS_CAST!>as? Klass<!>
}
fun test_1(a: Any?) {
(a as String?)!!
a.length
(a <!USELESS_CAST!>as? String<!>)!!
a.length
}
fun test_3(a: Any?) {
a as String
a <!USELESS_CAST!>as String<!>
}
fun test_4(a: Any?) {
a as String
a <!USELESS_CAST!>as? String<!>
}
fun test_5(a: Any?) {
(a as? String)!!
a.length
(a <!USELESS_CAST!>as String<!>)
}
fun test_6(a: Any?) {
(a as? String)!!
a.length
(a <!USELESS_CAST!>as? String<!>)
}