And last (for this topic reified type parameters) ...
# language-proposals
j
And last (for this topic reified type parameters) but not least, I would like to propose better smart-cast for reified types:
Copy code
inline fun <reified T: Action>T.reversedAction(): T {
    // If I do not use the constant `me` here, but `this`, `this` 
    // would be smart casted to `TemporalAction`, but *loose* its type `T`
    // but it should have both then!
    val me = this
    return when (me) {
        is TemporalAction -> {
            val copy = this.copy()
            (copy as TemporalAction).isReverse = !copy.isReverse
            copy
        }
        // other cases 
        else -> this
    }
}
I would like to be able to do it like this:
Copy code
inline fun <reified T: Action>T.reversedAction(): T {
    return when (this) {
        is TemporalAction -> {
            val copy = this.copy()
            copy.isReverse = !copy.isReverse
            copy
        }
        // other cases 
        else -> this
    }
}