fun main(args: Array) { try { val x = cast(Any()) println(x.length) } catch (e: Throwable) { println("Ok") } } fun cast(x: Any?) = x as T