diff --git a/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java b/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java index aafad5d3529..9e47f4221f7 100644 --- a/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java +++ b/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java @@ -570,7 +570,7 @@ public class JsAstMapper { // String fnNameIdent = fromFnNameNode.getString(); if (fnNameIdent != null && fnNameIdent.length() > 0) { - scopeContext.globalNameFor(fnNameIdent); + toFn.setName(scopeContext.globalNameFor(fnNameIdent)); } while (fromParamNode != null) { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index d892be88c82..c43b2603013 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -4967,6 +4967,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { doTest(fileName); } + @TestMetadata("functionName.kt") + public void testFunctionName() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsCode/functionName.kt"); + doTest(fileName); + } + @TestMetadata("if.kt") public void testIf() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsCode/if.kt"); diff --git a/js/js.translator/testData/box/jsCode/functionName.kt b/js/js.translator/testData/box/jsCode/functionName.kt new file mode 100644 index 00000000000..9ce1c26f9c8 --- /dev/null +++ b/js/js.translator/testData/box/jsCode/functionName.kt @@ -0,0 +1,8 @@ +fun box(): String { + return js(""" + function foo() { + return "OK"; + } + foo(); + """) +} \ No newline at end of file