diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java index fa8a8ab14e3..01dfb0ce76e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionTest.java @@ -154,4 +154,8 @@ public class FunctionTest extends AbstractExpressionTest { public void testLambdaOrLocalFunInsideEnumMethod() throws Exception { checkFooBoxIsOk(); } + + public void testManglingClashFunctionsAndClasses() throws Exception { + checkFooBoxIsOk(); + } } diff --git a/js/js.translator/testData/expression/function/cases/manglingClashFunctionsAndClasses.kt b/js/js.translator/testData/expression/function/cases/manglingClashFunctionsAndClasses.kt new file mode 100644 index 00000000000..372b4fa216a --- /dev/null +++ b/js/js.translator/testData/expression/function/cases/manglingClashFunctionsAndClasses.kt @@ -0,0 +1,45 @@ +package foo + +public class A + +fun A(a: Int){} + +public class B(a: Int) + +fun B(){} + +fun C(a: Int){} + +public class C + +fun D(){} + +public class D(a: Int) + +//Testing + +fun testClass(name: String, f: () -> Unit) { + val fs = f.toString() + + if ("$name(" !in fs) throw Exception("Name of class '$name' unexpectedly mangled: $fs") +} + +fun testFun(name: String, f: () -> Unit) { + val fs = f.toString() + + if ("$name(" in fs) throw Exception("Name of fun '$name' unexpectedly not mangled: $fs") +} + + +fun box(): String { + testClass("A") { A() } + testFun("A") { A(1) } + testFun("B") { B() } + testClass("B") { B(1) } + testClass("C") { C() } + testFun("C") { C(1) } + testFun("D") { D() } + testClass("D") { D(1) } + + return "OK" +}