JS: fix KT-37386
Anonymous object constructor parameters should not reuse JsName's of the super class. Otherwise the temporary name renamer gets confused.
This commit is contained in:
+5
@@ -6243,6 +6243,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/objectDeclaration/kt3684.kt");
|
runTest("js/js.translator/testData/box/objectDeclaration/kt3684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37386.kt")
|
||||||
|
public void testKt37386() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/objectDeclaration/kt37386.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInObjectInsideObject.kt")
|
@TestMetadata("lambdaInObjectInsideObject.kt")
|
||||||
public void testLambdaInObjectInsideObject() throws Exception {
|
public void testLambdaInObjectInsideObject() throws Exception {
|
||||||
runTest("js/js.translator/testData/box/objectDeclaration/lambdaInObjectInsideObject.kt");
|
runTest("js/js.translator/testData/box/objectDeclaration/lambdaInObjectInsideObject.kt");
|
||||||
|
|||||||
+5
@@ -6263,6 +6263,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/objectDeclaration/kt3684.kt");
|
runTest("js/js.translator/testData/box/objectDeclaration/kt3684.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37386.kt")
|
||||||
|
public void testKt37386() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/objectDeclaration/kt37386.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaInObjectInsideObject.kt")
|
@TestMetadata("lambdaInObjectInsideObject.kt")
|
||||||
public void testLambdaInObjectInsideObject() throws Exception {
|
public void testLambdaInObjectInsideObject() throws Exception {
|
||||||
runTest("js/js.translator/testData/box/objectDeclaration/lambdaInObjectInsideObject.kt");
|
runTest("js/js.translator/testData/box/objectDeclaration/lambdaInObjectInsideObject.kt");
|
||||||
|
|||||||
+2
-5
@@ -49,10 +49,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.*;
|
import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.*;
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.FunctionBodyTranslator.setDefaultValueForArguments;
|
import static org.jetbrains.kotlin.js.translate.utils.FunctionBodyTranslator.setDefaultValueForArguments;
|
||||||
@@ -232,7 +229,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (ValueParameterDescriptor parameter : superDescriptor.getValueParameters()) {
|
for (ValueParameterDescriptor parameter : superDescriptor.getValueParameters()) {
|
||||||
JsName parameterName = context.getNameForDescriptor(parameter);
|
JsName parameterName = JsScope.declareTemporaryName(parameter.getName().asString());
|
||||||
arguments.add(parameterName.makeRef());
|
arguments.add(parameterName.makeRef());
|
||||||
initializer.getParameters().add(new JsParameter(parameterName));
|
initializer.getParameters().add(new JsParameter(parameterName));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 1315
|
||||||
|
|
||||||
|
fun foo() = "OK"
|
||||||
|
|
||||||
|
open class A(val foo: Boolean = true) {
|
||||||
|
val ok = foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
val q = object : A() {}
|
||||||
|
|
||||||
|
fun box() = q.ok
|
||||||
Reference in New Issue
Block a user