do not store jvm class name in descriptor name

This commit is contained in:
Stepan Koltsov
2012-06-02 02:55:42 +04:00
parent fc6c57e17a
commit 4a01a55480
4 changed files with 32 additions and 23 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen;
import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
@@ -74,8 +75,8 @@ public class ClosureAnnotator {
classDescriptor = new ClassDescriptorImpl( classDescriptor = new ClassDescriptorImpl(
funDescriptor, funDescriptor,
Collections.<AnnotationDescriptor>emptyList(), Collections.<AnnotationDescriptor>emptyList(),
// TODO: internal name used as identifier Name.special("<closure>"));
Name.identifier(name.getInternalName())); // TODO: recordName(classDescriptor, name);
classDescriptor.initialize( classDescriptor.initialize(
false, false,
Collections.<TypeParameterDescriptor>emptyList(), Collections.<TypeParameterDescriptor>emptyList(),
@@ -264,18 +265,6 @@ public class ClosureAnnotator {
classStack.pop(); classStack.pop();
} }
// TODO: please insert either @NotNull or @Nullable here
// stepan.koltsov@ 2012-04-08
private void recordName(ClassDescriptor classDescriptor, @NotNull JvmClassName name) {
JvmClassName old = classNamesForClassDescriptor.put(classDescriptor, name);
if (old == null) {
// TODO: fix this assertion
// previosly here was incorrect assert that was ignored without -ea
// stepan.koltsov@ 2012-04-08
//throw new IllegalStateException("rewrite at key " + classDescriptor);
}
}
@Override @Override
public void visitProperty(JetProperty property) { public void visitProperty(JetProperty property) {
nameStack.push(nameStack.peek() + '$' + property.getName()); nameStack.push(nameStack.peek() + '$' + property.getName());
@@ -316,9 +305,25 @@ public class ClosureAnnotator {
} }
} }
public JvmClassName classNameForClassDescriptor(ClassDescriptor classDescriptor) { // TODO: please insert either @NotNull or @Nullable here
JvmClassName name = classNamesForClassDescriptor.get(classDescriptor); // stepan.koltsov@ 2012-04-08
assert name != null; private void recordName(ClassDescriptor classDescriptor, @NotNull JvmClassName name) {
return name; JvmClassName old = classNamesForClassDescriptor.put(classDescriptor, name);
if (old == null) {
// TODO: fix this assertion
// previosly here was incorrect assert that was ignored without -ea
// stepan.koltsov@ 2012-04-08
//throw new IllegalStateException("rewrite at key " + classDescriptor);
}
}
@NotNull
public JvmClassName classNameForClassDescriptor(@NotNull ClassDescriptor classDescriptor) {
return classNamesForClassDescriptor.get(classDescriptor);
}
@Nullable
public JvmClassName classNameForClassDescriptorIfDefined(@NotNull ClassDescriptor classDescriptor) {
return classNamesForClassDescriptor.get(classDescriptor);
} }
} }
@@ -334,9 +334,13 @@ public class JetTypeMapper {
.getInternalName(); .getInternalName();
} }
// This is the worst code in the project if (descriptor instanceof ClassDescriptor) {
if(name.getName().contains("/")) ClassDescriptor clazz = (ClassDescriptor) descriptor;
return name.getName(); JvmClassName className = closureAnnotator.classNameForClassDescriptorIfDefined(clazz);
if (className != null) {
return className.getInternalName();
}
}
if (container != null) { if (container != null) {
String baseName = getFQName(container); String baseName = getFQName(container);
@@ -41,7 +41,7 @@ public class Name implements Comparable<Name> {
if (special) { if (special) {
throw new IllegalStateException("not identifier: " + this); throw new IllegalStateException("not identifier: " + this);
} }
return name; return getName();
} }
public boolean isSpecial() { public boolean isSpecial() {
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public class NameUtils { public class NameUtils {
public static boolean isValidIdentified(@NotNull String name) { public static boolean isValidIdentified(@NotNull String name) {
return name.length() > 0 && !name.startsWith("<") && !name.contains("."); return name.length() > 0 && !name.startsWith("<") && !name.contains(".") && !name.contains("/");
} }
public static void requireIdentifier(@NotNull String name) { public static void requireIdentifier(@NotNull String name) {