Hi. Is following behavior expected? Code: ``` fun ...
# announcements
v
Hi. Is following behavior expected? Code:
Copy code
fun testOverrideWithNothing() {
    class A {
        override fun toString(): String = throw Exception("Don't call toString() on A")
    }

    class B {
        override fun toString()/*: Nothing*/ = throw Exception("Don't call toString() on B")
    }

    println("1) " + try {"" + A()} catch (e: Throwable) {"Died saying: ${e.message}"})
    println("2) " + try {"" + B()} catch (e: Throwable) {"Died saying: ${e.message}"})
}
Output:
Copy code
1) Died saying: Don't call toString() on A
2) Kotlin_jvm_playgroundKt$testOverrideWithNothing$B@6e0be858