Is it possible to add smart cast for such cases? `...
# language-evolution
r
Is it possible to add smart cast for such cases?
Copy code
data class EmployeeDetailedDTO(val firstName: String)

class EmployeesRepository {

    inline fun <reified T> findPage(isDeleted: Boolean = false): List<T> {
        return when(T::class) {
            EmployeeDetailedDTO::class -> listOf(EmployeeDetailedDTO("John")) as List<T>
            else -> TODO()
        }
    }
}
so, it will not be needed to add
as List<T>
1
m
I wonder if contracts can be used to somehow achieve this in 1.4: https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released#contracts-support