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);
|
||||
}
|
||||
|
||||
@TestMetadata("catch.kt")
|
||||
public void testCatch() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/catch.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("chainedCall.kt")
|
||||
public void testChainedCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/chainedCall.kt");
|
||||
|
||||
+4
-2
@@ -85,7 +85,9 @@ class CatchTranslator(
|
||||
initialCatchParameterRef: JsNameRef,
|
||||
catches: Iterator<KtCatchClause>
|
||||
): JsStatement {
|
||||
if (!catches.hasNext()) return JsThrow(initialCatchParameterRef)
|
||||
if (!catches.hasNext()) {
|
||||
return JsThrow(initialCatchParameterRef)
|
||||
}
|
||||
|
||||
var nextContext = context
|
||||
|
||||
@@ -117,7 +119,7 @@ class CatchTranslator(
|
||||
}!!
|
||||
|
||||
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 {
|
||||
|
||||
+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