Fix JS source maps for companion objects of enum
This commit is contained in:
@@ -102,6 +102,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enumCompanionObject.kt")
|
||||||
|
public void testEnumCompanionObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/enumCompanionObject.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");
|
||||||
|
|||||||
+2
-1
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForType
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForType
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForTypeConstructor
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForTypeConstructor
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
||||||
|
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||||
import org.jetbrains.kotlin.types.CommonSupertypes.topologicallySortSuperclassesAndRecordAllInstances
|
import org.jetbrains.kotlin.types.CommonSupertypes.topologicallySortSuperclassesAndRecordAllInstances
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
import org.jetbrains.kotlin.types.SimpleType
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor
|
import org.jetbrains.kotlin.types.TypeConstructor
|
||||||
@@ -89,7 +90,7 @@ class ClassTranslator private constructor(
|
|||||||
val companionDescriptor = descriptor.companionObjectDescriptor
|
val companionDescriptor = descriptor.companionObjectDescriptor
|
||||||
if (enumInitFunction != null && companionDescriptor != null) {
|
if (enumInitFunction != null && companionDescriptor != null) {
|
||||||
val initInvocation = JsInvocation(JsAstUtils.pureFqn(context().getNameForObjectInstance(companionDescriptor), null))
|
val initInvocation = JsInvocation(JsAstUtils.pureFqn(context().getNameForObjectInstance(companionDescriptor), null))
|
||||||
enumInitFunction.body.statements += JsAstUtils.asSyntheticStatement(initInvocation)
|
enumInitFunction.body.statements += JsAstUtils.asSyntheticStatement(initInvocation.source(companionDescriptor.source.getPsi()))
|
||||||
}
|
}
|
||||||
|
|
||||||
translatePrimaryConstructor(constructorFunction, context, delegationTranslator)
|
translatePrimaryConstructor(constructorFunction, context, delegationTranslator)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
enum class Foo {
|
||||||
|
A;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val a = A
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LINES: 1 1 1 1 2 4 * 2 2 4 5 * 4 4 4 4 * 1 * 1 1 1 1
|
||||||
Reference in New Issue
Block a user