kt2470.kt 402 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// KT-2470 another name mangling bug: kotlin.test.failsWith() gets generated to invalid JS

package foo

public fun <T : Throwable> failsWith(block: () -> Any): T {
    try {
        block()
    }
    catch (e: T) {
        return e
    }

    throw Exception("Should have failed")
}

fun box(): String {
    val a = failsWith<Exception> {
        throw Exception("OK")
    }

21
    return a.message!!
22
}