[FIR] Report CANNOT_CHECK_FOR_ERASED independent of reified parameters

This changes the logic so that Foo<T> is reported no matter if T is
reified or not. Even for Array<reified T> to align K2 with K1 logic.

#KT-55903 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-28 16:44:24 +02:00
committed by Space Team
parent bbee881b5b
commit 3bfb0866cb
4 changed files with 49 additions and 17 deletions
@@ -15,13 +15,28 @@ fun <T, S : T> test(x: T?, y: S, z: T) {
null <!UNCHECKED_CAST!>as S<!>
}
inline fun <reified T> test(x: T?) {
class Box<T>
inline fun <reified T> test(x: T?, a: Any) {
x is T
null as T
null <!USELESS_CAST!>as T?<!>
a is T
a as T
a is <!CANNOT_CHECK_FOR_ERASED!>Box<T><!>
a is <!CANNOT_CHECK_FOR_ERASED!>Array<T><!>
a <!UNCHECKED_CAST!>as Box<T><!>
a <!UNCHECKED_CAST!>as Array<T><!>
a is <!CANNOT_CHECK_FOR_ERASED!>Box<List<T>><!>
a is <!CANNOT_CHECK_FOR_ERASED!>Array<List<T>><!>
a <!UNCHECKED_CAST!>as Box<List<T>><!>
a <!UNCHECKED_CAST!>as Array<List<T>><!>
}
fun <T> foo(x: List<T>, y: List<T>?) {
<!USELESS_IS_CHECK!>x is List<T><!>
y is List<T>
}
}