diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index 4c185794a87..1d5de1ec66f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -581,7 +581,7 @@ public class FunctionCodegen extends GenerationStateAware { JvmClassName ownerInternalName; if (contextClass instanceof NamespaceDescriptor) { - ownerInternalName = NamespaceCodegen.getJVMClassNameForKotlinNs(DescriptorUtils.getFQName(contextClass).toSafe()); + ownerInternalName = state.getTypeMapper().getOwner(functionDescriptor, kind, true); } else { ownerInternalName = JvmClassName.byType(state.getTypeMapper() diff --git a/compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt b/compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt new file mode 100644 index 00000000000..daa98f7c949 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt @@ -0,0 +1,4 @@ +fun foo(a: Int = 1) {} + +//0 _DefaultPackage.foo +//3 INVOKESTATIC _DefaultPackage\$src\$ \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/BytecodeTextTestGenerated.java index 70572aea489..945b9461252 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/BytecodeTextTestGenerated.java @@ -77,6 +77,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { doTest("compiler/testData/codegen/bytecodeText/privateDefaultArgs.kt"); } + @TestMetadata("topLevelFunWithDefaultArgs.kt") + public void testTopLevelFunWithDefaultArgs() throws Exception { + doTest("compiler/testData/codegen/bytecodeText/topLevelFunWithDefaultArgs.kt"); + } + @TestMetadata("compiler/testData/codegen/bytecodeText/statements") public static class Statements extends AbstractBytecodeTextTest { public void testAllFilesPresentInStatements() throws Exception {