Is it possible to have a function that returns a generic type? Something like:
fun <T> doSomething() : T {
when {
T is Boolean -> somethingThatReturnsBoolean()
T is Int -> somethingThatReturnsInt()
else -> throw Exception("Unhandled return type")
}
}