Has there been any prior consideration into extend...
# language-proposals
s
Has there been any prior consideration into extending smart casting to support type parameters, such that something like the following could be possible? (Or is some variation of this already possible?)
Copy code
sealed class Foo<T> {
    object FooBool : Foo<Boolean>()
    object FooInt : Foo<Int>()
}

fun <T> match(x: Foo<T>): T = when (x) {
    is Foo.FooBool -> true
    is Foo.FooInt -> 42
}
This is considered currently a
minor
problem. To me is major as impacts pretty much every program involving adts and generics which is a very popular programming style.
plus1 1
s
Thank you 👍
I did actually come by this by looking to translate some existing GADT code.