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 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.psi.*;
@@ -74,8 +75,8 @@ public class ClosureAnnotator {
classDescriptor = new ClassDescriptorImpl(
funDescriptor,
Collections.<AnnotationDescriptor>emptyList(),
// TODO: internal name used as identifier
Name.identifier(name.getInternalName())); // TODO:
Name.special("<closure>"));
recordName(classDescriptor, name);
classDescriptor.initialize(
false,
Collections.<TypeParameterDescriptor>emptyList(),
@@ -264,18 +265,6 @@ public class ClosureAnnotator {
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
public void visitProperty(JetProperty property) {
nameStack.push(nameStack.peek() + '$' + property.getName());
@@ -316,9 +305,25 @@ public class ClosureAnnotator {
}
}
public JvmClassName classNameForClassDescriptor(ClassDescriptor classDescriptor) {
JvmClassName name = classNamesForClassDescriptor.get(classDescriptor);
assert name != null;
return name;
// 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);
}
}
@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();
}
// This is the worst code in the project
if(name.getName().contains("/"))
return name.getName();
if (descriptor instanceof ClassDescriptor) {
ClassDescriptor clazz = (ClassDescriptor) descriptor;
JvmClassName className = closureAnnotator.classNameForClassDescriptorIfDefined(clazz);
if (className != null) {
return className.getInternalName();
}
}
if (container != null) {
String baseName = getFQName(container);
@@ -41,7 +41,7 @@ public class Name implements Comparable<Name> {
if (special) {
throw new IllegalStateException("not identifier: " + this);
}
return name;
return getName();
}
public boolean isSpecial() {
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public class NameUtils {
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) {