diff --git a/compiler/testData/codegen/box/intrinsics/throwableParamOrder.kt b/compiler/testData/codegen/box/intrinsics/throwableParamOrder.kt index fe1f09305d4..7708a6de220 100644 --- a/compiler/testData/codegen/box/intrinsics/throwableParamOrder.kt +++ b/compiler/testData/codegen/box/intrinsics/throwableParamOrder.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR var res = "" fun getM(): String { diff --git a/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt b/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt index e50e8bb11d1..cd0501bdf1d 100644 --- a/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt +++ b/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class CustomException : Throwable { constructor(message: String?, cause: Throwable?) : super(message, cause) diff --git a/compiler/testData/codegen/box/specialBuiltins/throwable.kt b/compiler/testData/codegen/box/specialBuiltins/throwable.kt index b9c1a57f325..e4040a63794 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwable.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwable.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { try { throw Throwable("OK", null) diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableCause.kt b/compiler/testData/codegen/box/specialBuiltins/throwableCause.kt index 14ea9c9b413..ade7379bb50 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableCause.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableCause.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR fun box(): String { var t = Throwable("O", Throwable("K")) if (t.message != "O" || t.cause?.message != "K") return "fail1" diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt b/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt new file mode 100644 index 00000000000..094664b432d --- /dev/null +++ b/compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt @@ -0,0 +1,42 @@ +open class Base(message: String? = null, cause: Throwable? = null) : Throwable(message, cause) + +open class Base2(message: String? = null, cause: Throwable? = null): Base(message, cause) + +open class Override(message: String? = null, cause: Throwable? = null) : Base2(message, cause) { + + var i = 0 + + override val message: String? + get() = "Override: " + super.message + "${i++}" +} + +open class OverBase(message: String? = null, cause: Throwable? = null): Override(message, cause) + +open class OverOverride(message: String? = null, cause: Throwable? = null) : OverBase(message, cause) { + + override val message: String? + get() = "OverOver: " + super.message + "${i++}" + + override val cause: Throwable? + get() = super.cause ?: this + +} + + +fun box(): String { + check(Base("O", Base("K")), "OK") + check(Override("OK"), "Override: OK0") + check(OverOverride("OK"), "OverOver: Override: OK01OverOver: Override: OK23") + return "OK" +} + + +fun check(t: Throwable, msg: String) { + try { + throw t + } catch (e: Throwable) { + val c = t.cause + val m = if (c != null) t.message!! + c.message!! else t.message!! + if (m != msg) throw AssertionError(m) + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt b/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt index 8343622751b..ad070a0298c 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class MyThrowable(message: String? = null, cause: Throwable? = null) : Throwable(message, cause) { override val message: String? diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt b/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt index 60b85b9a046..afa627c4598 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR class MyThrowable : Throwable { val x: String diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 0a344876fc0..0ae3db8aa93 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -21768,6 +21768,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/specialBuiltins/throwableCause.kt"); } + @TestMetadata("throwableComplex.kt") + public void testThrowableComplex() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt"); + } + @TestMetadata("throwableImpl.kt") public void testThrowableImpl() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 8aee2cfbe96..2581c147a32 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21768,6 +21768,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/specialBuiltins/throwableCause.kt"); } + @TestMetadata("throwableComplex.kt") + public void testThrowableComplex() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt"); + } + @TestMetadata("throwableImpl.kt") public void testThrowableImpl() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 5b7e9f931e0..fe3afe86f3b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -21773,6 +21773,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/specialBuiltins/throwableCause.kt"); } + @TestMetadata("throwableComplex.kt") + public void testThrowableComplex() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt"); + } + @TestMetadata("throwableImpl.kt") public void testThrowableImpl() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index a19a09a9f4c..68fff3a18bd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -19588,6 +19588,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/specialBuiltins/throwableCause.kt"); } + @TestMetadata("throwableComplex.kt") + public void testThrowableComplex() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt"); + } + @TestMetadata("throwableImpl.kt") public void testThrowableImpl() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index a37025a9dca..a005a243cbd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -20633,6 +20633,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/specialBuiltins/throwableCause.kt"); } + @TestMetadata("throwableComplex.kt") + public void testThrowableComplex() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/throwableComplex.kt"); + } + @TestMetadata("throwableImpl.kt") public void testThrowableImpl() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/throwableImpl.kt"); diff --git a/js/js.translator/testData/box/expression/try/kt22053.kt b/js/js.translator/testData/box/expression/try/kt22053.kt index 4d3f4fea844..f849fdd05bd 100644 --- a/js/js.translator/testData/box/expression/try/kt22053.kt +++ b/js/js.translator/testData/box/expression/try/kt22053.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1291 package foo diff --git a/js/js.translator/testData/box/jsCode/catchScope.kt b/js/js.translator/testData/box/jsCode/catchScope.kt index adf7caf885d..87ee7ab3207 100644 --- a/js/js.translator/testData/box/jsCode/catchScope.kt +++ b/js/js.translator/testData/box/jsCode/catchScope.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1286 package foo