Keep exception primary constructors for binary compatibility in JS
Resort to a workaround for KT-22053 in direct Throwable inheritors.
This commit is contained in:
@@ -3,6 +3,9 @@ package foo
|
||||
|
||||
class MyException(m: String? = null): Exception(m)
|
||||
class MyException2(m: String? = null): Throwable(m)
|
||||
// TODO: add direct inheritors of Throwable:
|
||||
// - with secondary constructors
|
||||
// - with cause only, in the primary constructor
|
||||
|
||||
fun check(e: Throwable, expectedString: String) {
|
||||
try {
|
||||
@@ -16,8 +19,14 @@ fun check(e: Throwable, expectedString: String) {
|
||||
fun box(): String {
|
||||
check(Throwable(), "Throwable: null")
|
||||
check(Throwable("ccc"), "Throwable: ccc")
|
||||
check(Throwable(Throwable("ddd")), "Throwable: Throwable: ddd")
|
||||
check(Exception(), "Exception: null")
|
||||
check(Exception("bbb"), "Exception: bbb")
|
||||
check(Exception(Exception("ccc")), "Exception: Exception: ccc")
|
||||
check(AssertionError(), "AssertionError: null")
|
||||
check(AssertionError(null), "AssertionError: null")
|
||||
check(AssertionError("bbb"), "AssertionError: bbb")
|
||||
check(AssertionError(Exception("ccc")), "AssertionError: Exception: ccc")
|
||||
check(MyException(), "MyException: null")
|
||||
check(MyException("aaa"), "MyException: aaa")
|
||||
check(MyException2(), "MyException2: null")
|
||||
|
||||
Reference in New Issue
Block a user