[JS IR] Generate context dependent names for anonymous objects and classes.
This commit is contained in:
committed by
Space
parent
b1643075f2
commit
a34c97ebd5
@@ -280,6 +280,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/classObject"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentClassObjectName.kt")
|
||||
public void testContextDependentClassObjectName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/classObject/contextDependentClassObjectName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultObjectSameNamesAsInOuter.kt")
|
||||
public void testDefaultObjectSameNamesAsInOuter() throws Exception {
|
||||
@@ -524,6 +530,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/closure/closureVarToScopeWithSameNameDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentClosureName.kt")
|
||||
public void testContextDependentClosureName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/closure/contextDependentClosureName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deepInnerClassInLocalClass.kt")
|
||||
public void testDeepInnerClassInLocalClass() throws Exception {
|
||||
@@ -6691,6 +6703,22 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/local")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Local {
|
||||
@Test
|
||||
public void testAllFilesPresentInLocal() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/local"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentLocalClassName.kt")
|
||||
public void testContextDependentLocalClassName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/local/contextDependentLocalClassName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -7788,6 +7816,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/objectDeclaration"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentObjectName.kt")
|
||||
public void testContextDependentObjectName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/objectDeclaration/contextDependentObjectName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dontPolluteObject.kt")
|
||||
public void testDontPolluteObject() throws Exception {
|
||||
|
||||
+34
@@ -280,6 +280,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/classObject"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentClassObjectName.kt")
|
||||
public void testContextDependentClassObjectName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/classObject/contextDependentClassObjectName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultObjectSameNamesAsInOuter.kt")
|
||||
public void testDefaultObjectSameNamesAsInOuter() throws Exception {
|
||||
@@ -524,6 +530,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/closure/closureVarToScopeWithSameNameDeclaration.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentClosureName.kt")
|
||||
public void testContextDependentClosureName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/closure/contextDependentClosureName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deepInnerClassInLocalClass.kt")
|
||||
public void testDeepInnerClassInLocalClass() throws Exception {
|
||||
@@ -7075,6 +7087,22 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/local")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Local {
|
||||
@Test
|
||||
public void testAllFilesPresentInLocal() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/local"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentLocalClassName.kt")
|
||||
public void testContextDependentLocalClassName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/local/contextDependentLocalClassName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("js/js.translator/testData/box/main")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -8172,6 +8200,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/objectDeclaration"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextDependentObjectName.kt")
|
||||
public void testContextDependentObjectName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/objectDeclaration/contextDependentObjectName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dontPolluteObject.kt")
|
||||
public void testDontPolluteObject() throws Exception {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class MyClass {
|
||||
companion object {
|
||||
fun ok(): String {
|
||||
val okMaker = object {
|
||||
fun getOk(): String = "OK"
|
||||
}
|
||||
return okMaker.getOk()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CHECK_FUNCTION_EXISTS: MyClass$Companion$ok$okMaker$1 TARGET_BACKENDS=JS_IR
|
||||
fun box(): String {
|
||||
return MyClass.ok()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo(a: () -> Unit) = a()
|
||||
|
||||
// CHECK_CALLED_IN_SCOPE: scope=box function=box$lambda
|
||||
fun box(): String {
|
||||
var result = "FAILURE"
|
||||
foo { result = "OK" }
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// CHECK_FUNCTION_EXISTS: box$MyClass TARGET_BACKENDS=JS_IR
|
||||
// CHECK_FUNCTION_EXISTS: box$MyClass$ok$InternalClass TARGET_BACKENDS=JS_IR
|
||||
fun box(): String {
|
||||
class MyClass {
|
||||
fun ok(): String {
|
||||
class InternalClass {
|
||||
fun getOk(): String = "OK"
|
||||
}
|
||||
return InternalClass().getOk()
|
||||
}
|
||||
}
|
||||
return MyClass().ok()
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
// CHECK_FUNCTION_EXISTS: box$a$1 TARGET_BACKENDS=JS_IR
|
||||
// CHECK_FUNCTION_EXISTS: box$a$1$run$b$1 TARGET_BACKENDS=JS_IR
|
||||
fun box(): String {
|
||||
var result = "FAILURE"
|
||||
|
||||
val a: A = object : A {
|
||||
override fun run() {
|
||||
val b = object {
|
||||
fun foo() {
|
||||
result = "OK"
|
||||
}
|
||||
}
|
||||
b.foo()
|
||||
}
|
||||
}
|
||||
|
||||
a.run()
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user