isPrimitiveNumberClassDescriptor() fixed to actually check the classes
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
@@ -43,6 +44,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -70,6 +72,16 @@ public class CodegenUtil {
|
||||
.put(Visibilities.LOCAL, NO_FLAG_LOCAL)
|
||||
.build();
|
||||
|
||||
private static final Set<ClassDescriptor> PRIMITIVE_NUMBER_CLASSES = Sets.newHashSet(
|
||||
JetStandardLibrary.getInstance().getByte(),
|
||||
JetStandardLibrary.getInstance().getShort(),
|
||||
JetStandardLibrary.getInstance().getInt(),
|
||||
JetStandardLibrary.getInstance().getLong(),
|
||||
JetStandardLibrary.getInstance().getFloat(),
|
||||
JetStandardLibrary.getInstance().getDouble(),
|
||||
JetStandardLibrary.getInstance().getChar()
|
||||
);
|
||||
|
||||
private CodegenUtil() {
|
||||
}
|
||||
|
||||
@@ -326,6 +338,13 @@ public class CodegenUtil {
|
||||
return type.getSort() != Type.OBJECT && type.getSort() != Type.ARRAY;
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveNumberClassDescriptor(DeclarationDescriptor descriptor) {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
return PRIMITIVE_NUMBER_CLASSES.contains(descriptor);
|
||||
}
|
||||
|
||||
public static Type correctElementType(Type type) {
|
||||
String internalName = type.getInternalName();
|
||||
assert internalName.charAt(0) == '[';
|
||||
|
||||
@@ -2462,16 +2462,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return StackValue.onStack(exprType);
|
||||
}
|
||||
|
||||
private static boolean isPrimitiveNumberClassDescriptor(DeclarationDescriptor descriptor) {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
String className = descriptor.getName().getName();
|
||||
return className.equals("Int") || className.equals("Long") || className.equals("Short") ||
|
||||
className.equals("Byte") || className.equals("Char") || className.equals("Float") ||
|
||||
className.equals("Double");
|
||||
}
|
||||
|
||||
private static boolean isClass(DeclarationDescriptor descriptor, String name) {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user