|
|
|
@@ -61,7 +61,6 @@ public class JetTypeMapper {
|
|
|
|
|
public static final Type TYPE_NOTHING = Type.getObjectType("jet/Nothing");
|
|
|
|
|
public static final Type JL_NUMBER_TYPE = Type.getObjectType("java/lang/Number");
|
|
|
|
|
public static final Type JL_STRING_BUILDER = Type.getObjectType("java/lang/StringBuilder");
|
|
|
|
|
public static final Type JL_ARRAY_LIST = Type.getObjectType("java/util/ArrayList");
|
|
|
|
|
public static final Type JL_STRING_TYPE = Type.getObjectType("java/lang/String");
|
|
|
|
|
public static final Type JL_CHAR_SEQUENCE_TYPE = Type.getObjectType("java/lang/CharSequence");
|
|
|
|
|
private static final Type JL_COMPARABLE_TYPE = Type.getObjectType("java/lang/Comparable");
|
|
|
|
@@ -302,19 +301,6 @@ public class JetTypeMapper {
|
|
|
|
|
return mapType(jetType, signatureVisitor, MapTypeMode.VALUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getStableNameForObject(JetObjectDeclaration object, DeclarationDescriptor descriptor) {
|
|
|
|
|
String local = getLocalNameForObject(object);
|
|
|
|
|
if (local == null) return null;
|
|
|
|
|
|
|
|
|
|
ClassDescriptor containingClass = getContainingClass(descriptor);
|
|
|
|
|
if (containingClass != null) {
|
|
|
|
|
return getClassFQName(containingClass).getInternalName() + "$" + local;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return getFQName(getContainingNamespace(descriptor)) + "/" + local;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getLocalNameForObject(JetObjectDeclaration object) {
|
|
|
|
|
PsiElement parent = object.getParent();
|
|
|
|
|
if (parent instanceof JetClassObject) {
|
|
|
|
@@ -386,18 +372,6 @@ public class JetTypeMapper {
|
|
|
|
|
return name.getIdentifier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) {
|
|
|
|
|
DeclarationDescriptor parent = descriptor.getContainingDeclaration();
|
|
|
|
|
if (parent == null || parent instanceof ClassDescriptor) return (ClassDescriptor) parent;
|
|
|
|
|
return getContainingClass(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static NamespaceDescriptor getContainingNamespace(DeclarationDescriptor descriptor) {
|
|
|
|
|
DeclarationDescriptor parent = descriptor.getContainingDeclaration();
|
|
|
|
|
if (parent == null || parent instanceof NamespaceDescriptor) return (NamespaceDescriptor) parent;
|
|
|
|
|
return getContainingNamespace(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
public Type mapType(@NotNull final JetType jetType, @NotNull MapTypeMode kind) {
|
|
|
|
|
return mapType(jetType, null, kind);
|
|
|
|
@@ -531,6 +505,7 @@ public class JetTypeMapper {
|
|
|
|
|
Type type = mapType(((TypeParameterDescriptor) descriptor).getUpperBoundsAsType(), kind);
|
|
|
|
|
if (signatureVisitor != null) {
|
|
|
|
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) jetType.getConstructor().getDeclarationDescriptor();
|
|
|
|
|
assert typeParameterDescriptor != null;
|
|
|
|
|
signatureVisitor.writeTypeVariable(typeParameterDescriptor.getName(), jetType.isNullable(), type);
|
|
|
|
|
}
|
|
|
|
|
checkValidType(type);
|
|
|
|
@@ -565,11 +540,10 @@ public class JetTypeMapper {
|
|
|
|
|
private void checkValidType(@NotNull Type type) {
|
|
|
|
|
if (!mapBuiltinsToJava) {
|
|
|
|
|
String descriptor = type.getDescriptor();
|
|
|
|
|
if (descriptor.equals("Ljava/lang/Object;")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (descriptor.startsWith("Ljava/")) {
|
|
|
|
|
throw new IllegalStateException("builtins must not reference java.* classes: " + descriptor);
|
|
|
|
|
if (!descriptor.equals("Ljava/lang/Object;")) {
|
|
|
|
|
if (descriptor.startsWith("Ljava/")) {
|
|
|
|
|
throw new IllegalStateException("builtins must not reference java.* classes: " + descriptor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -849,7 +823,6 @@ public class JetTypeMapper {
|
|
|
|
|
|
|
|
|
|
if(kind == OwnerKind.TRAIT_IMPL) {
|
|
|
|
|
ClassDescriptor containingDeclaration = (ClassDescriptor) parentDescriptor;
|
|
|
|
|
assert containingDeclaration != null;
|
|
|
|
|
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
|
|
|
|
mapType(containingDeclaration.getDefaultType(), signatureWriter, MapTypeMode.IMPL);
|
|
|
|
|
signatureWriter.writeParameterTypeEnd();
|
|
|
|
@@ -890,7 +863,6 @@ public class JetTypeMapper {
|
|
|
|
|
String name = PropertyCodegen.setterName(descriptor.getName());
|
|
|
|
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
|
|
|
|
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
|
|
|
|
assert containingDeclaration != null;
|
|
|
|
|
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
|
|
|
|
mapType(containingDeclaration.getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
|
|
|
|
signatureWriter.writeParameterTypeEnd();
|
|
|
|
@@ -1048,7 +1020,7 @@ public class JetTypeMapper {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isForceReal(JvmClassName className) {
|
|
|
|
|
private static boolean isForceReal(JvmClassName className) {
|
|
|
|
|
return JvmPrimitiveType.getByWrapperClass(className) != null
|
|
|
|
|
|| className.getFqName().getFqName().equals("java.lang.String")
|
|
|
|
|
|| className.getFqName().getFqName().equals("java.lang.CharSequence")
|
|
|
|
@@ -1057,22 +1029,8 @@ public class JetTypeMapper {
|
|
|
|
|
|| className.getFqName().getFqName().equals("java.lang.Comparable");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isGenericsArray(JetType type) {
|
|
|
|
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
|
|
|
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (JetStandardLibraryNames.ARRAY.is(type)) {
|
|
|
|
|
return isGenericsArray(type.getArguments().get(0).getType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JetType getGenericsElementType(JetType arrayType) {
|
|
|
|
|
JetType type = arrayType.getArguments().get(0).getType();
|
|
|
|
|
return isGenericsArray(type) ? type : null;
|
|
|
|
|
public static boolean isGenericsArray(JetType type) {
|
|
|
|
|
return JetStandardLibraryNames.ARRAY.is(type) && type.getArguments().get(0).getType().getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
|
|
|
|