Fix generation of JS source maps for closures

This commit is contained in:
Alexey Andreev
2017-05-04 17:14:17 +03:00
parent 3a7df13440
commit 28140b0883
3 changed files with 16 additions and 2 deletions
@@ -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("closure.kt")
public void testClosure() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/closure.kt");
doTest(fileName);
}
@TestMetadata("inlining.kt")
public void testInlining() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/inlining.kt");
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ class LiteralFunctionTranslator(context: TranslationContext) : AbstractTranslato
val tracker = functionContext.usageTracker()!!
if (tracker.hasCapturedExceptContaining()) {
val lambdaCreator = simpleReturnFunction(invokingContext.scope(), lambda)
val lambdaCreator = simpleReturnFunction(invokingContext.scope(), lambda.source(declaration))
lambdaCreator.name = invokingContext.getInnerNameForDescriptor(descriptor)
lambdaCreator.isLocal = true
if (descriptor in tracker.capturedDescriptors && !descriptor.isCoroutineLambda) {
+8
View File
@@ -0,0 +1,8 @@
fun box(x: Int, y: Int): Int {
fun foo(
z: Int) =
x + z
return foo(y)
}
// LINES: 2 4 2 5