KT-864 wrong namespace class name generation
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -173,10 +173,10 @@ public class GenerationState {
|
||||
final ClassFileFactory factory = getFactory();
|
||||
List<String> 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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<ArrayList<String>>{it.toArrayList()}
|
||||
|
||||
if(arrayList("Hello", "World") != list1) return "fail"
|
||||
if(arrayList("Hello", "World") != list2) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -76,4 +76,8 @@ public class StdlibTest extends CodegenTestCase {
|
||||
public void testKt715 () {
|
||||
blackBoxFile("regressions/kt715.kt");
|
||||
}
|
||||
|
||||
public void testKt864 () {
|
||||
blackBoxFile("regressions/kt864.jet");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ArrayList<String>>{it.toArrayList()}
|
||||
val list1 = sample().useLines{it.toArrayList()}
|
||||
val list2 = sample().useLines<ArrayList<String>>{it.toArrayList()}
|
||||
|
||||
assertEquals(arrayList("Hello", "World"), list)
|
||||
*/
|
||||
assertEquals(arrayList("Hello", "World"), list1)
|
||||
assertEquals(arrayList("Hello", "World"), list2)
|
||||
}
|
||||
|
||||
fun testUse() {
|
||||
|
||||
Reference in New Issue
Block a user