diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java index 98aee0c5402..34c01e7effc 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java @@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.types.JetType; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; @@ -86,10 +87,11 @@ public abstract class CodegenContext { } public String getNamespaceClassName() { - if(parentContext != STATIC) - return parentContext.getNamespaceClassName(); - - return NamespaceCodegen.getJVMClassName(contextType.getName()); + DeclarationDescriptor descriptor = contextType; + while(!(descriptor instanceof NamespaceDescriptor)) { + descriptor = descriptor.getContainingDeclaration(); + } + return NamespaceCodegen.getJVMClassName(DescriptorUtils.getFQName(descriptor)); } public OwnerKind getContextKind() { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java index db142585742..99539cb3875 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/GenerationState.java @@ -173,10 +173,10 @@ public class GenerationState { final ClassFileFactory factory = getFactory(); List files = factory.files(); for (String file : files) { - if (!file.startsWith("std/")) { +// if (!file.startsWith("std/")) { answer.append("@").append(file).append('\n'); answer.append(factory.asText(file)); - } +// } } return answer.toString(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java index 29ec1038894..31bc00c6667 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java @@ -119,7 +119,7 @@ public class NamespaceCodegen { private void generateTypeInfoFields(JetFile file, CodegenContext context) { if(context.typeInfoConstants != null) { - String jvmClassName = getJVMClassName(file.getNamespaceHeader().getName()); + String jvmClassName = getJVMClassName(JetPsiUtil.getFQName(file)); for(int index = 0; index != context.typeInfoConstantsCount; index++) { JetType type = context.reverseTypeInfoConstants.get(index); String fieldName = "$typeInfoCache$" + index; diff --git a/compiler/testData/codegen/regressions/kt864.jet b/compiler/testData/codegen/regressions/kt864.jet new file mode 100644 index 00000000000..40bdba3dade --- /dev/null +++ b/compiler/testData/codegen/regressions/kt864.jet @@ -0,0 +1,20 @@ +import std.io.* +import std.util.* +import java.io.* +import java.util.* + +fun sample() : Reader { + return StringReader("""Hello +World"""); + } + + fun box() : String { + // TODO compiler error + // both these expressions causes java.lang.NoClassDefFoundError: collections/namespace + val list1 = sample().useLines{it.toArrayList()} + val list2 = sample().useLines>{it.toArrayList()} + + if(arrayList("Hello", "World") != list1) return "fail" + if(arrayList("Hello", "World") != list2) return "fail" + return "OK" + } diff --git a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java index 5fe45a47098..af96165738f 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java @@ -76,4 +76,8 @@ public class StdlibTest extends CodegenTestCase { public void testKt715 () { blackBoxFile("regressions/kt715.kt"); } + + public void testKt864 () { + blackBoxFile("regressions/kt864.jet"); + } } diff --git a/testlib/test/IoTest.kt b/testlib/test/IoTest.kt index 6057432243a..5714c8445ff 100644 --- a/testlib/test/IoTest.kt +++ b/testlib/test/IoTest.kt @@ -24,14 +24,11 @@ World"""); } fun testLineIterator() { - /* - // TODO compiler error - // both these expressions causes java.lang.NoClassDefFoundError: collections/namespace - val list = sample().useLines{it.toArrayList()} - val list = sample().useLines>{it.toArrayList()} + val list1 = sample().useLines{it.toArrayList()} + val list2 = sample().useLines>{it.toArrayList()} - assertEquals(arrayList("Hello", "World"), list) - */ + assertEquals(arrayList("Hello", "World"), list1) + assertEquals(arrayList("Hello", "World"), list2) } fun testUse() {