Don't call .getFqName() when writing package src class name
Package$src class names contain dollars, and JvmClassName.getFqName() doesn't work very well for such names
This commit is contained in:
@@ -669,4 +669,11 @@ public class AsmUtil {
|
||||
public static String asmDescByFqNameWithoutInnerClasses(@NotNull FqName fqName) {
|
||||
return "L" + JvmClassName.byFqNameWithoutInnerClasses(fqName).getInternalName() + ';';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String shortNameByAsmType(@NotNull Type type) {
|
||||
String internalName = type.getInternalName();
|
||||
int lastSlash = internalName.lastIndexOf('/');
|
||||
return lastSlash < 0 ? internalName : internalName.substring(lastSlash + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.*;
|
||||
@@ -113,8 +112,8 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
OwnerKind contextKind = owner.getContextKind();
|
||||
if (contextKind instanceof OwnerKind.StaticDelegateKind) {
|
||||
FqName fqName = ((OwnerKind.StaticDelegateKind) contextKind).getOwnerClass().getFqName();
|
||||
v.getMemberMap().recordSrcClassNameForCallable(functionDescriptor, fqName.shortName());
|
||||
JvmClassName ownerName = ((OwnerKind.StaticDelegateKind) contextKind).getOwnerClass();
|
||||
v.getMemberMap().recordSrcClassNameForCallable(functionDescriptor, shortNameByAsmType(ownerName.getAsmType()));
|
||||
}
|
||||
else {
|
||||
v.getMemberMap().recordMethodOfDescriptor(functionDescriptor, asmMethod);
|
||||
|
||||
@@ -21,7 +21,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.jet.descriptors.serialization.*;
|
||||
import org.jetbrains.jet.descriptors.serialization.JavaProtoBuf;
|
||||
import org.jetbrains.jet.descriptors.serialization.NameTable;
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||
import org.jetbrains.jet.descriptors.serialization.SerializerExtension;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -93,9 +96,9 @@ public class JavaSerializerExtension extends SerializerExtension {
|
||||
@NotNull ProtoBuf.Callable.Builder proto,
|
||||
@NotNull NameTable nameTable
|
||||
) {
|
||||
Name name = memberMap.getSrcClassNameOfCallable(callable);
|
||||
String name = memberMap.getSrcClassNameOfCallable(callable);
|
||||
if (name != null) {
|
||||
proto.setExtension(JavaProtoBuf.srcClassName, nameTable.getSimpleNameIndex(name));
|
||||
proto.setExtension(JavaProtoBuf.srcClassName, nameTable.getSimpleNameIndex(Name.identifier(name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -32,7 +31,7 @@ public final class MemberMap {
|
||||
private final Map<FunctionDescriptor, Method> methodForFunction = new HashMap<FunctionDescriptor, Method>();
|
||||
private final Map<PropertyDescriptor, Pair<Type, String>> fieldForProperty = new HashMap<PropertyDescriptor, Pair<Type, String>>();
|
||||
private final Map<PropertyDescriptor, String> syntheticMethodNameForProperty = new HashMap<PropertyDescriptor, String>();
|
||||
private final Map<CallableMemberDescriptor, Name> srcClassNameForCallable = new HashMap<CallableMemberDescriptor, Name>();
|
||||
private final Map<CallableMemberDescriptor, String> srcClassNameForCallable = new HashMap<CallableMemberDescriptor, String>();
|
||||
private final Set<PropertyDescriptor> staticFieldInOuterClass = new HashSet<PropertyDescriptor>();
|
||||
|
||||
@NotNull
|
||||
@@ -51,7 +50,7 @@ public final class MemberMap {
|
||||
result.recordSyntheticMethodNameOfProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<CallableMemberDescriptor, Name> entry : map.srcClassNameForCallable.entrySet()) {
|
||||
for (Map.Entry<CallableMemberDescriptor, String> entry : map.srcClassNameForCallable.entrySet()) {
|
||||
result.recordSrcClassNameForCallable(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@@ -78,8 +77,8 @@ public final class MemberMap {
|
||||
assert old == null : "Duplicate synthetic method for property: " + descriptor + "; " + old;
|
||||
}
|
||||
|
||||
public void recordSrcClassNameForCallable(@NotNull CallableMemberDescriptor descriptor, @NotNull Name name) {
|
||||
Name old = srcClassNameForCallable.put(descriptor, name);
|
||||
public void recordSrcClassNameForCallable(@NotNull CallableMemberDescriptor descriptor, @NotNull String name) {
|
||||
String old = srcClassNameForCallable.put(descriptor, name);
|
||||
assert old == null : "Duplicate src class name for callable: " + descriptor + "; " + old;
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ public final class MemberMap {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Name getSrcClassNameOfCallable(@NotNull CallableMemberDescriptor descriptor) {
|
||||
public String getSrcClassNameOfCallable(@NotNull CallableMemberDescriptor descriptor) {
|
||||
return srcClassNameForCallable.get(descriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +37,14 @@ import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.getDeprecatedAccessFlag;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.getVisibilityForSpecialPropertyBackingField;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.getParentBodyCodegen;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.isInterface;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
@@ -89,8 +88,8 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
: "Generating property with a wrong kind (" + kind + "): " + propertyDescriptor;
|
||||
|
||||
if (kind instanceof OwnerKind.StaticDelegateKind) {
|
||||
FqName fqName = ((OwnerKind.StaticDelegateKind) kind).getOwnerClass().getFqName();
|
||||
v.getMemberMap().recordSrcClassNameForCallable(propertyDescriptor, fqName.shortName());
|
||||
JvmClassName ownerName = ((OwnerKind.StaticDelegateKind) kind).getOwnerClass();
|
||||
v.getMemberMap().recordSrcClassNameForCallable(propertyDescriptor, shortNameByAsmType(ownerName.getAsmType()));
|
||||
}
|
||||
else if (kind != OwnerKind.TRAIT_IMPL) {
|
||||
generateBackingField(p, propertyDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user