Reputation: 1743
I have this piece of code
inline fun <reified T>store(dataList: List<T>) {
when (T::class.java) {
MyClass::class.java -> this.sasses = dataList as List<MyClass>
The as List<MyClass>
issues a warning:
Unchecked cast: List to List
I'm pretty sure my code is safe but how to silence this warning?
Thanks!
Upvotes: 0
Views: 83
Reputation: 3930
Use filterIsInstance
to avoid this warning. like
inline fun <reified T>store(dataList: List<T>) {
when (T::class.java) {
MyClass::class.java -> this.sasses = dataList.filterIsInstance<MyClass>()
Upvotes: 1