Checks for primitive types and arrays made static in KotlinBuiltIns

This commit is contained in:
Andrey Breslav
2014-12-02 16:40:54 +03:00
parent b275b363c9
commit c21dd366e0
11 changed files with 41 additions and 27 deletions
@@ -851,7 +851,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
protected void assignToLoopParameter() {
Type arrayElParamType;
if (KotlinBuiltIns.getInstance().isArray(loopRangeType)) {
if (KotlinBuiltIns.isArray(loopRangeType)) {
arrayElParamType = boxType(asmElementType);
}
else {
@@ -3438,7 +3438,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
args.add(va.getArgumentExpression());
}
boolean isArray = KotlinBuiltIns.getInstance().isArray(arrayType);
boolean isArray = KotlinBuiltIns.isArray(arrayType);
if (!isArray && args.size() != 1) {
throw new CompilationException("primitive array constructor requires one argument", null, expression);
}
@@ -3492,7 +3492,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
public void newArrayInstruction(@NotNull JetType arrayType) {
if (KotlinBuiltIns.getInstance().isArray(arrayType)) {
if (KotlinBuiltIns.isArray(arrayType)) {
JetType elementJetType = arrayType.getArguments().get(0).getType();
putReifierMarkerIfTypeIsReifiedParameter(
elementJetType,
@@ -3519,7 +3519,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
operationDescriptor.getValueParameters().get(0).getType().equals(KotlinBuiltIns.getInstance().getIntType())) {
assert type != null;
Type elementType;
if (KotlinBuiltIns.getInstance().isArray(type)) {
if (KotlinBuiltIns.isArray(type)) {
JetType jetElementType = type.getArguments().get(0).getType();
elementType = boxType(asmType(jetElementType));
}
@@ -264,7 +264,7 @@ public class JetTypeMapper {
return asmType;
}
if (descriptor instanceof ClassDescriptor && KotlinBuiltIns.getInstance().isArray(jetType)) {
if (descriptor instanceof ClassDescriptor && KotlinBuiltIns.isArray(jetType)) {
if (jetType.getArguments().size() != 1) {
throw new UnsupportedOperationException("arrays must have one type argument");
}
@@ -683,11 +683,11 @@ public class JetTypeMapper {
*/
private static boolean forceBoxedReturnType(@NotNull FunctionDescriptor descriptor) {
//noinspection ConstantConditions
if (!KotlinBuiltIns.getInstance().isPrimitiveType(descriptor.getReturnType())) return false;
if (!KotlinBuiltIns.isPrimitiveType(descriptor.getReturnType())) return false;
for (FunctionDescriptor overridden : getAllOverriddenDescriptors(descriptor)) {
//noinspection ConstantConditions
if (!KotlinBuiltIns.getInstance().isPrimitiveType(overridden.getOriginal().getReturnType())) return true;
if (!KotlinBuiltIns.isPrimitiveType(overridden.getOriginal().getReturnType())) return true;
}
return false;