JS: fix generation of source map for inline lambda with ignored result
See KT-21309
This commit is contained in:
+5
-2
@@ -49,7 +49,10 @@ class ReturnReplacingVisitor(
|
||||
if (returnExpression != null && returnExpression.isTailCallSuspend) {
|
||||
returnReplacement.isSuspend = true
|
||||
}
|
||||
ctx.addNext(JsExpressionStatement(returnReplacement.apply { source = x.source }))
|
||||
if (returnReplacement.source == null) {
|
||||
returnReplacement.source = x.source
|
||||
}
|
||||
ctx.addNext(JsExpressionStatement(returnReplacement))
|
||||
}
|
||||
|
||||
if (breakLabel != null) {
|
||||
@@ -70,7 +73,7 @@ class ReturnReplacingVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
fun processCoroutineResult(expression: JsExpression?): JsExpression? {
|
||||
private fun processCoroutineResult(expression: JsExpression?): JsExpression? {
|
||||
if (!isSuspend) return expression
|
||||
if (expression != null && expression.isTailCallSuspend) return expression
|
||||
val lhs = JsNameRef("\$\$coroutineResult\$\$", JsAstUtils.stateMachineReceiver()).apply { coroutineResult = true }
|
||||
|
||||
@@ -228,6 +228,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionInInlineLambda.kt")
|
||||
public void testLastExpressionInInlineLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/lastExpressionInInlineLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("literals.kt")
|
||||
public void testLiterals() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/literals.kt");
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
fun foo() {
|
||||
bar {
|
||||
try {
|
||||
baz()
|
||||
}
|
||||
catch (e: RuntimeException) {
|
||||
e.toString()
|
||||
}
|
||||
}
|
||||
|
||||
bar {
|
||||
when (boo()) {
|
||||
"boo" -> baz()
|
||||
else -> "111"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun bar(x: () -> String): String {
|
||||
return x()
|
||||
}
|
||||
|
||||
fun baz() = "baz"
|
||||
|
||||
fun boo() = "boo"
|
||||
|
||||
// LINES: 17 4 6 6 7 7 3 3 3 * 13 12 13 13 14 21 20 20 23 23 23 25 25 25
|
||||
Reference in New Issue
Block a user