Fix JS source maps for complex enum entry
This commit is contained in:
@@ -120,6 +120,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumObject.kt")
|
||||||
|
public void testEnumObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/enumObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("expressionAsFunctionBody.kt")
|
@TestMetadata("expressionAsFunctionBody.kt")
|
||||||
public void testExpressionAsFunctionBody() throws Exception {
|
public void testExpressionAsFunctionBody() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/expressionAsFunctionBody.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/expressionAsFunctionBody.kt");
|
||||||
|
|||||||
+1
@@ -197,6 +197,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
|||||||
|
|
||||||
if (classDeclaration instanceof KtEnumEntry) {
|
if (classDeclaration instanceof KtEnumEntry) {
|
||||||
JsExpression expression = CallTranslator.translate(context(), superCall, null);
|
JsExpression expression = CallTranslator.translate(context(), superCall, null);
|
||||||
|
expression.setSource(classDeclaration);
|
||||||
|
|
||||||
JsExpression fixedInvocation = AstUtilsKt.toInvocationWith(
|
JsExpression fixedInvocation = AstUtilsKt.toInvocationWith(
|
||||||
expression, getAdditionalArgumentsForEnumConstructor(), 0, new JsThisRef());
|
expression, getAdditionalArgumentsForEnumConstructor(), 0, new JsThisRef());
|
||||||
|
|||||||
@@ -69,12 +69,12 @@ fun JsExpression.toInvocationWith(
|
|||||||
is JsNew -> {
|
is JsNew -> {
|
||||||
qualifier = Namer.getFunctionCallRef(constructorExpression)
|
qualifier = Namer.getFunctionCallRef(constructorExpression)
|
||||||
// `new A(a, b, c)` -> `A.call($this, a, b, c)`
|
// `new A(a, b, c)` -> `A.call($this, a, b, c)`
|
||||||
return JsInvocation(qualifier, listOf(thisExpr) + leadingExtraArgs + arguments)
|
return JsInvocation(qualifier, listOf(thisExpr) + leadingExtraArgs + arguments).source(source)
|
||||||
}
|
}
|
||||||
is JsInvocation -> {
|
is JsInvocation -> {
|
||||||
qualifier = getQualifier()
|
qualifier = getQualifier()
|
||||||
// `A(a, b, c)` -> `A(a, b, c, $this)`
|
// `A(a, b, c)` -> `A(a, b, c, $this)`
|
||||||
return JsInvocation(qualifier, leadingExtraArgs + padArguments(arguments) + thisExpr)
|
return JsInvocation(qualifier, leadingExtraArgs + padArguments(arguments) + thisExpr).source(source)
|
||||||
}
|
}
|
||||||
else -> throw IllegalStateException("Unexpected node type: " + this::class.java)
|
else -> throw IllegalStateException("Unexpected node type: " + this::class.java)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
enum class E {
|
||||||
|
X,
|
||||||
|
|
||||||
|
Y {
|
||||||
|
fun foo() = 23
|
||||||
|
},
|
||||||
|
|
||||||
|
Z() {
|
||||||
|
fun bar() = 42
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LINES: 1 1 1 1 2 4 8 * 2 2 4 4 5 * 4 4 8 8 9 * 8 8 * 1 * 1 1 1 1 1 1
|
||||||
Reference in New Issue
Block a user