Fix JS source maps for catch blocks
This commit is contained in:
@@ -36,6 +36,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/lineNumbers"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/lineNumbers"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("catch.kt")
|
||||||
|
public void testCatch() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/catch.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("chainedCall.kt")
|
@TestMetadata("chainedCall.kt")
|
||||||
public void testChainedCall() throws Exception {
|
public void testChainedCall() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/chainedCall.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/chainedCall.kt");
|
||||||
|
|||||||
+4
-2
@@ -85,7 +85,9 @@ class CatchTranslator(
|
|||||||
initialCatchParameterRef: JsNameRef,
|
initialCatchParameterRef: JsNameRef,
|
||||||
catches: Iterator<KtCatchClause>
|
catches: Iterator<KtCatchClause>
|
||||||
): JsStatement {
|
): JsStatement {
|
||||||
if (!catches.hasNext()) return JsThrow(initialCatchParameterRef)
|
if (!catches.hasNext()) {
|
||||||
|
return JsThrow(initialCatchParameterRef)
|
||||||
|
}
|
||||||
|
|
||||||
var nextContext = context
|
var nextContext = context
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ class CatchTranslator(
|
|||||||
}!!
|
}!!
|
||||||
|
|
||||||
val elseBlock = translateCatches(context, initialCatchParameterRef, catches)
|
val elseBlock = translateCatches(context, initialCatchParameterRef, catches)
|
||||||
return JsIf(typeCheck, thenBlock, elseBlock)
|
return JsIf(typeCheck.source(catch), thenBlock, elseBlock).apply { source = catch }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun translateCatchBody(context: TranslationContext, catchClause: KtCatchClause): JsBlock {
|
private fun translateCatchBody(context: TranslationContext, catchClause: KtCatchClause): JsBlock {
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
fun box() {
|
||||||
|
try {
|
||||||
|
println("foo")
|
||||||
|
}
|
||||||
|
catch (e: RuntimeException) {
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
println("baz")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() {
|
||||||
|
try {
|
||||||
|
println("foo")
|
||||||
|
}
|
||||||
|
catch (e: dynamic) {
|
||||||
|
println("bar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LINES: 3 5 6 8 9 * 15 18
|
||||||
Reference in New Issue
Block a user