// IGNORE_BACKEND: JS fun something(): T = Any() as T class Context fun Any.decodeIn(typeFrom: Context): T = something() fun Any?.decodeOut(typeFrom: Context): T { return this?.decodeIn(typeFrom) // decodeIn result is of type Nothing ?: throw AssertionError("") } fun box(): String { try { "str".decodeOut(Context()) } catch (e: Exception) { // TODO check FQN val exceptionClassName = e::class.simpleName if (exceptionClassName != "KotlinNothingValueException") { throw AssertionError("Unexpected exception: $e") } else { return "OK" } } throw AssertionError("Should fail with exception") }