Fix JS source map for char boxing and unboxing

This commit is contained in:
Alexey Andreev
2017-06-23 13:03:25 +03:00
parent be7f3a787c
commit ec2a5bf0ee
3 changed files with 32 additions and 2 deletions
@@ -60,6 +60,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
doTest(fileName);
}
@TestMetadata("charBoxing.kt")
public void testCharBoxing() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/charBoxing.kt");
doTest(fileName);
}
@TestMetadata("classCapturingLocals.kt")
public void testClassCapturingLocals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/classCapturingLocals.kt");
@@ -159,12 +159,16 @@ public final class JsAstUtils {
@NotNull
public static JsExpression charToBoxedChar(@NotNull JsExpression expression) {
return withBoxingMetadata(invokeKotlinFunction("toBoxedChar", unnestBoxing(expression)));
JsInvocation invocation = invokeKotlinFunction("toBoxedChar", unnestBoxing(expression));
invocation.setSource(expression.getSource());
return withBoxingMetadata(invocation);
}
@NotNull
public static JsExpression boxedCharToChar(@NotNull JsExpression expression) {
return withBoxingMetadata(invokeKotlinFunction("unboxChar", unnestBoxing(expression)));
JsInvocation invocation = invokeKotlinFunction("unboxChar", unnestBoxing(expression));
invocation.setSource(expression.getSource());
return withBoxingMetadata(invocation);
}
@NotNull
+20
View File
@@ -0,0 +1,20 @@
var log = ""
inline fun String.foo(a: String): Int {
log += "foo1"
return asDynamic().indexOf(a)
}
inline fun String.foo(a: Char): Int {
log += "foo2"
return indexOf(a.toString())
}
fun bar(a: String, b: Char, x: Int) {
log += if (x > 0)
23
else
a.foo(b)
}
// LINES: 6 4 4 5 5 11 9 9 10 10 18 14 14 14 14 14 15 17 9 9 14 10 17 10 14 14 * 1 * 1