Utilize existing mapType methods
Fix warnings related to nullable CallableDescriptor.getReturnType()
This commit is contained in:
@@ -36,7 +36,7 @@ import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.context.*;
|
||||
import org.jetbrains.jet.codegen.intrinsics.*;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
@@ -1639,7 +1639,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(memberDescriptor);
|
||||
if (intrinsic != null) {
|
||||
Type returnType = typeMapper.mapType(memberDescriptor.getReturnType());
|
||||
Type returnType = typeMapper.mapType(memberDescriptor);
|
||||
return intrinsic.generate(this, v, returnType, expression, Collections.<JetExpression>emptyList(), receiver, state);
|
||||
}
|
||||
}
|
||||
@@ -2021,7 +2021,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
args.add(argument.getArgumentExpression());
|
||||
}
|
||||
|
||||
Type returnType = typeMapper.mapType(resolvedCall.getResultingDescriptor().getReturnType());
|
||||
Type returnType = typeMapper.mapType(resolvedCall.getResultingDescriptor());
|
||||
|
||||
StackValue stackValue = intrinsic.generate(this, v, returnType, call.getCallElement(), args, receiver, state);
|
||||
stackValue.put(returnType, v);
|
||||
@@ -2667,10 +2667,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert op instanceof FunctionDescriptor : String.valueOf(op);
|
||||
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||
if (callable instanceof IntrinsicMethod) {
|
||||
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
||||
Type returnType = typeMapper.mapType(resolvedCall.getResultingDescriptor().getReturnType());
|
||||
return intrinsic.generate(this, v, returnType, expression,
|
||||
Arrays.asList(expression.getLeft(), expression.getRight()), receiver, state);
|
||||
//noinspection ConstantConditions
|
||||
Type returnType = typeMapper.mapType(resolvedCall.getResultingDescriptor());
|
||||
return ((IntrinsicMethod) callable).generate(this, v, returnType, expression,
|
||||
Arrays.asList(expression.getLeft(), expression.getRight()), receiver, state);
|
||||
}
|
||||
else {
|
||||
return invokeFunction(call, receiver, resolvedCall);
|
||||
@@ -2913,13 +2913,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
value.dupReceiver(v); // receiver receiver
|
||||
value.put(lhsType, v); // receiver lhs
|
||||
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
||||
//noinspection NullableProblems
|
||||
JetExpression right = expression.getRight();
|
||||
assert right != null;
|
||||
Type returnType = typeMapper.mapType(((FunctionDescriptor) op).getReturnType());
|
||||
StackValue stackValue = intrinsic.generate(this, v, returnType, expression,
|
||||
Arrays.asList(right),
|
||||
StackValue.onStack(lhsType), state);
|
||||
Type returnType = typeMapper.mapType((FunctionDescriptor) op);
|
||||
intrinsic.generate(this, v, returnType, expression, Collections.singletonList(right), StackValue.onStack(lhsType), state);
|
||||
value.store(lhsType, v);
|
||||
}
|
||||
else {
|
||||
@@ -3004,11 +3001,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert op instanceof FunctionDescriptor : String.valueOf(op);
|
||||
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||
if (callable instanceof IntrinsicMethod) {
|
||||
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
||||
//noinspection ConstantConditions
|
||||
Type returnType = typeMapper.mapType(((FunctionDescriptor) op).getReturnType());
|
||||
return intrinsic.generate(this, v, returnType, expression,
|
||||
Arrays.asList(expression.getBaseExpression()), receiver, state);
|
||||
Type returnType = typeMapper.mapType((FunctionDescriptor) op);
|
||||
return ((IntrinsicMethod) callable).generate(this, v, returnType, expression,
|
||||
Collections.singletonList(expression.getBaseExpression()), receiver, state);
|
||||
}
|
||||
else {
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
|
||||
@@ -33,12 +33,12 @@ public class FieldInfo {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
Type fieldType = typeMapper.mapType(fieldClassDescriptor.getDefaultType());
|
||||
Type fieldType = typeMapper.mapType(fieldClassDescriptor);
|
||||
|
||||
ClassDescriptor ownerDescriptor = kind == ClassKind.OBJECT
|
||||
? fieldClassDescriptor: DescriptorUtils.getParentOfType(fieldClassDescriptor, ClassDescriptor.class);
|
||||
assert ownerDescriptor != null;
|
||||
Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType());
|
||||
Type ownerType = typeMapper.mapType(ownerDescriptor);
|
||||
|
||||
String fieldName = kind == ClassKind.ENUM_ENTRY
|
||||
? fieldClassDescriptor.getName().asString()
|
||||
@@ -52,14 +52,11 @@ public class FieldInfo {
|
||||
}
|
||||
|
||||
private final Type fieldType;
|
||||
|
||||
private final Type ownerType;
|
||||
|
||||
private final String fieldName;
|
||||
|
||||
private final boolean isStatic;
|
||||
|
||||
private FieldInfo(@NotNull Type ownerType, @NotNull Type fieldType, @NotNull String fieldName, @NotNull boolean isStatic) {
|
||||
private FieldInfo(@NotNull Type ownerType, @NotNull Type fieldType, @NotNull String fieldName, boolean isStatic) {
|
||||
this.ownerType = ownerType;
|
||||
this.fieldType = fieldType;
|
||||
this.fieldName = fieldName;
|
||||
@@ -86,7 +83,6 @@ public class FieldInfo {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public boolean isStatic() {
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||
private Type getThisTypeForFunction(@NotNull FunctionDescriptor functionDescriptor, @NotNull MethodContext context) {
|
||||
ReceiverParameterDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
|
||||
if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||
return typeMapper.mapType(functionDescriptor.getReturnType());
|
||||
return typeMapper.mapType(functionDescriptor);
|
||||
}
|
||||
else if (expectedThisObject != null) {
|
||||
return typeMapper.mapType(expectedThisObject.getType());
|
||||
|
||||
@@ -654,7 +654,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
iv.store(2, AsmTypeConstants.OBJECT_TYPE);
|
||||
|
||||
for (PropertyDescriptor propertyDescriptor : properties) {
|
||||
Type asmType = typeMapper.mapType(propertyDescriptor.getType());
|
||||
Type asmType = typeMapper.mapType(propertyDescriptor);
|
||||
|
||||
genPropertyOnStack(iv, propertyDescriptor, 0);
|
||||
genPropertyOnStack(iv, propertyDescriptor, 2);
|
||||
@@ -702,7 +702,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
genPropertyOnStack(iv, propertyDescriptor, 0);
|
||||
|
||||
Label ifNull = null;
|
||||
Type asmType = typeMapper.mapType(propertyDescriptor.getType());
|
||||
Type asmType = typeMapper.mapType(propertyDescriptor);
|
||||
if (!isPrimitive(asmType)) {
|
||||
ifNull = new Label();
|
||||
iv.dup();
|
||||
@@ -829,7 +829,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateCopyFunction(@NotNull final FunctionDescriptor function) {
|
||||
JvmMethodSignature methodSignature = typeMapper.mapSignature(function);
|
||||
|
||||
final Type thisDescriptorType = typeMapper.mapType(descriptor.getDefaultType());
|
||||
final Type thisDescriptorType = typeMapper.mapType(descriptor);
|
||||
|
||||
functionCodegen.generateMethod(myClass, methodSignature, function, new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
@@ -888,7 +888,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
assert propertyDescriptor != null
|
||||
: "Trying to generate default value for parameter of copy function that doesn't correspond to any property";
|
||||
codegen.v.load(0, thisDescriptorType);
|
||||
Type propertyType = codegen.typeMapper.mapType(propertyDescriptor.getType());
|
||||
Type propertyType = codegen.typeMapper.mapType(propertyDescriptor);
|
||||
codegen.intermediateValueForProperty(propertyDescriptor, false, null)
|
||||
.put(propertyType, codegen.v);
|
||||
}
|
||||
@@ -1300,8 +1300,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
!propertyDescriptor.isVar() &&
|
||||
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
|
||||
// final property with backing field
|
||||
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classAsmType,
|
||||
propertyDescriptor.getName().asString(), false);
|
||||
field = StackValue.field(typeMapper.mapType(propertyDescriptor), classAsmType, propertyDescriptor.getName().asString(), false);
|
||||
}
|
||||
else {
|
||||
iv.load(0, classAsmType);
|
||||
@@ -1712,7 +1711,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
public static boolean shouldWriteFieldInitializer(PropertyDescriptor descriptor, JetTypeMapper mapper) {
|
||||
//final field of primitive or String type
|
||||
if (!descriptor.isVar()) {
|
||||
Type type = mapper.mapType(descriptor.getType());
|
||||
Type type = mapper.mapType(descriptor);
|
||||
return AsmUtil.isPrimitive(type) || "java.lang.String".equals(type.getClassName());
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -221,13 +221,14 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull VariableDescriptor variableDescriptor) {
|
||||
return mapType(variableDescriptor.getType(), null, JetTypeMapperMode.VALUE);
|
||||
public Type mapType(@NotNull CallableDescriptor descriptor) {
|
||||
//noinspection ConstantConditions
|
||||
return mapType(descriptor.getReturnType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
return mapType(classifierDescriptor.getDefaultType(), null, JetTypeMapperMode.VALUE);
|
||||
public Type mapType(@NotNull ClassifierDescriptor descriptor) {
|
||||
return mapType(descriptor.getDefaultType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user