Don't write "ResolvedCall<? extends CallableDescriptor>"

ResolvedCall has a type parameter D which extends CallableDescriptor.
Hence in Java "ResolvedCall<? extends CallableDescriptor>" = "ResolvedCall<?>"

The same story with these classes:
- ResolutionTask
- CallCandidateResolutionContext
- OverloadResolutionResults
This commit is contained in:
Alexander Udalov
2014-03-17 18:39:04 +04:00
parent 7d6423fcf1
commit 8b18309b01
38 changed files with 131 additions and 194 deletions
@@ -86,8 +86,7 @@ public abstract class AnnotationCodegen {
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
for (JetAnnotationEntry annotationEntry : annotationEntries) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry);
@@ -464,7 +464,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
// Is it a "1..2" or so
RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression);
if (binaryCall != null) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(RESOLVED_CALL, binaryCall.op);
ResolvedCall<?> resolvedCall = bindingContext.get(RESOLVED_CALL, binaryCall.op);
if (resolvedCall != null) {
if (RangeCodegenUtil.isOptimizableRangeTo(resolvedCall.getResultingDescriptor())) {
generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
@@ -1625,7 +1625,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, StackValue receiver) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
DeclarationDescriptor descriptor;
if (resolvedCall == null) {
@@ -1894,7 +1894,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetExpression callee = expression.getCalleeExpression();
assert callee != null;
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
if (resolvedCall == null) {
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
}
@@ -1922,11 +1922,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return invokeFunction(call, receiver, resolvedCall);
}
private StackValue invokeSamConstructor(
JetCallExpression expression,
ResolvedCall<? extends CallableDescriptor> resolvedCall,
JavaClassDescriptor samInterface
) {
@NotNull
private StackValue invokeSamConstructor(JetCallExpression expression, ResolvedCall<?> resolvedCall, JavaClassDescriptor samInterface) {
List<ResolvedValueArgument> arguments = resolvedCall.getValueArgumentsByIndex();
if (arguments == null) {
throw new IllegalStateException("Failed to arrange value arguments by index: " + resolvedCall.getResultingDescriptor());
@@ -1994,11 +1991,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
@NotNull
public StackValue invokeFunction(
Call call,
StackValue receiver,
ResolvedCall<? extends CallableDescriptor> resolvedCall
) {
public StackValue invokeFunction(Call call, StackValue receiver, ResolvedCall<?> resolvedCall) {
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return invokeFunction(call, receiver, ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall());
}
@@ -2034,7 +2027,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private StackValue invokeFunctionWithCalleeOnStack(
@NotNull Call call,
@NotNull StackValue receiver,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull ResolvedCall<?> resolvedCall,
@NotNull Callable callable
) {
if (callable instanceof CallableMethod) {
@@ -2118,7 +2111,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
public void invokeMethodWithArguments(
@Nullable Call call,
@NotNull CallableMethod callableMethod,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull ResolvedCall<?> resolvedCall,
@NotNull StackValue receiver
) {
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
@@ -2159,11 +2152,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
callGenerator.genCall(callable, resolvedCall, mask, this);
}
private void genThisAndReceiverFromResolvedCall(
StackValue receiver,
ResolvedCall<? extends CallableDescriptor> resolvedCall,
CallableMethod callableMethod
) {
private void genThisAndReceiverFromResolvedCall(StackValue receiver, ResolvedCall<?> resolvedCall, CallableMethod callableMethod) {
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod);
receiver.put(receiver.type, v);
}
@@ -2461,7 +2450,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
assert functionDescriptor != null : "Callable reference is not resolved to descriptor: " + expression.getText();
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
ResolvedCall<?> resolvedCall = bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
assert resolvedCall != null : "Callable reference is not resolved: " + functionDescriptor + " " + expression.getText();
JetType kFunctionType = bindingContext.get(EXPRESSION_TYPE, expression);
@@ -2482,13 +2471,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private static class CallableReferenceGenerationStrategy extends FunctionGenerationStrategy.CodegenBased<FunctionDescriptor> {
private final ResolvedCall<? extends CallableDescriptor> resolvedCall;
private final ResolvedCall<?> resolvedCall;
private final FunctionDescriptor referencedFunction;
public CallableReferenceGenerationStrategy(
@NotNull GenerationState state,
@NotNull FunctionDescriptor functionDescriptor,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall
@NotNull ResolvedCall<?> resolvedCall
) {
super(state, functionDescriptor);
this.resolvedCall = resolvedCall;
@@ -2704,7 +2693,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return generateIn(StackValue.expression(Type.INT_TYPE, expression.getLeft(), this), expression.getRight(), reference);
}
else {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, reference);
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, reference);
Call call = bindingContext.get(BindingContext.CALL, reference);
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, reference);
@@ -2912,8 +2901,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
gen(right, type);
}
else {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
Call call = bindingContext.get(BindingContext.CALL, expression.getOperationReference());
StackValue result = invokeFunction(call, receiver, resolvedCall);
type = Type.INT_TYPE;
@@ -2975,8 +2963,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private void callAugAssignMethod(JetBinaryExpression expression, CallableMethod callable, Type lhsType, boolean keepReturnValue) {
JetSimpleNameExpression reference = expression.getOperationReference();
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, reference);
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, reference);
Call call = bindingContext.get(BindingContext.CALL, reference);
assert resolvedCall != null : "Resolved call should be not null for operation reference in " + expression.getText();
@@ -3047,8 +3034,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
DeclarationDescriptor cls = op.getContainingDeclaration();
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
@@ -3131,7 +3117,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
storeType = type;
}
else {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
CallableMethod callableMethod = (CallableMethod) callable;
@@ -3273,7 +3259,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull
private StackValue generateNewCall(
@NotNull JetCallExpression expression,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull ResolvedCall<?> resolvedCall,
@NotNull StackValue receiver
) {
Type type = expressionType(expression);
@@ -3286,11 +3272,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
@NotNull
private StackValue generateConstructorCall(
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull StackValue receiver,
@NotNull Type type
) {
private StackValue generateConstructorCall(@NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver, @NotNull Type type) {
v.anew(type);
v.dup();
@@ -3805,8 +3787,7 @@ The "returned" value of try expression with no finally is either the last expres
}
private void invokeFunctionByReference(JetSimpleNameExpression operationReference) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(RESOLVED_CALL, operationReference);
ResolvedCall<?> resolvedCall = bindingContext.get(RESOLVED_CALL, operationReference);
Call call = bindingContext.get(CALL, operationReference);
invokeFunction(call, StackValue.none(), resolvedCall);
}
@@ -1322,7 +1322,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
PropertyDescriptor propertyDescriptor = null;
if (expression instanceof JetSimpleNameExpression) {
ResolvedCall<? extends CallableDescriptor> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
ResolvedCall<?> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
if (call != null) {
CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
if (callResultingDescriptor instanceof ValueParameterDescriptor) {
@@ -1549,8 +1549,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor);
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, ((JetCallElement) superCall).getCalleeExpression());
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, ((JetCallElement) superCall).getCalleeExpression());
assert resolvedCall != null;
ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
@@ -1651,7 +1650,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
throw new UnsupportedOperationException("unsupported type of enum constant initializer: " + specifier);
}
ResolvedCall<? extends CallableDescriptor> resolvedCall =
ResolvedCall<?> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, ((JetDelegatorToSuperCall) specifier).getCalleeExpression());
assert resolvedCall != null : "Enum entry delegation specifier is unresolved: " + specifier.getText();
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Label;
import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.asm4.commons.Method;
import org.jetbrains.asm4.tree.MethodNode;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
@@ -326,7 +325,7 @@ public abstract class StackValue {
}
public static StackValue receiver(
ResolvedCall<? extends CallableDescriptor> resolvedCall,
ResolvedCall<?> resolvedCall,
StackValue receiver,
ExpressionCodegen codegen,
@Nullable CallableMethod callableMethod
@@ -775,7 +774,7 @@ public abstract class StackValue {
}
}
private boolean isStandardStack(ResolvedCall call, int valueParamsSize) {
private boolean isStandardStack(ResolvedCall<?> call, int valueParamsSize) {
if (call == null) {
return true;
}
@@ -1099,14 +1098,14 @@ public abstract class StackValue {
}
public static class CallReceiver extends StackValue {
private final ResolvedCall<? extends CallableDescriptor> resolvedCall;
private final ResolvedCall<?> resolvedCall;
final StackValue receiver;
private final ExpressionCodegen codegen;
private final CallableMethod callableMethod;
private final boolean putReceiverArgumentOnStack;
public CallReceiver(
ResolvedCall<? extends CallableDescriptor> resolvedCall,
ResolvedCall<?> resolvedCall,
StackValue receiver,
ExpressionCodegen codegen,
CallableMethod callableMethod,
@@ -1120,11 +1119,7 @@ public abstract class StackValue {
this.putReceiverArgumentOnStack = putReceiverArgumentOnStack;
}
private static Type calcType(
ResolvedCall<? extends CallableDescriptor> resolvedCall,
ExpressionCodegen codegen,
CallableMethod callableMethod
) {
private static Type calcType(ResolvedCall<?> resolvedCall, ExpressionCodegen codegen, CallableMethod callableMethod) {
ReceiverValue thisObject = resolvedCall.getThisObject();
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
@@ -64,7 +64,7 @@ public class TailRecursionCodegen {
return status != null && status.isDoGenerateTailRecursion();
}
public void generateTailRecursion(ResolvedCall<? extends CallableDescriptor> resolvedCall) {
public void generateTailRecursion(ResolvedCall<?> resolvedCall) {
CallableDescriptor fd = resolvedCall.getResultingDescriptor();
assert fd instanceof FunctionDescriptor : "Resolved call doesn't refer to the function descriptor: " + fd;
CallableMethod callable = (CallableMethod) codegen.resolveToCallable((FunctionDescriptor) fd, false);
@@ -107,7 +107,7 @@ public class TailRecursionCodegen {
JetExpression argumentExpression = argument == null ? null : argument.getArgumentExpression();
if (argumentExpression instanceof JetSimpleNameExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = state.getBindingContext().get(RESOLVED_CALL, argumentExpression);
ResolvedCall<?> resolvedCall = state.getBindingContext().get(RESOLVED_CALL, argumentExpression);
if (resolvedCall != null && resolvedCall.getResultingDescriptor().equals(parameterDescriptor.getOriginal())) {
// do nothing: we shouldn't store argument to itself again
AsmUtil.pop(v, type);
@@ -314,8 +314,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
// working around a problem with shallow analysis
if (functionDescriptor == null) return;
ResolvedCall<? extends CallableDescriptor> referencedFunction =
bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
ResolvedCall<?> referencedFunction = bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
if (referencedFunction == null) return;
JetType superType = getSuperTypeForClosure((FunctionDescriptor) referencedFunction.getResultingDescriptor(), true);
@@ -406,7 +405,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
@Override
public void visitCallExpression(@NotNull JetCallExpression expression) {
super.visitCallExpression(expression);
ResolvedCall<? extends CallableDescriptor> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
ResolvedCall<?> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
if (call == null) {
return;
}
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression;
@@ -46,7 +45,7 @@ public class JavaClassArray extends IntrinsicMethod {
@Nullable List<JetExpression> arguments,
StackValue receiver
) {
ResolvedCall<? extends CallableDescriptor> call =
ResolvedCall<?> call =
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression());
assert call != null;
Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> next = call.getValueArguments().entrySet().iterator().next();
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -48,8 +47,7 @@ public class JavaClassFunction extends IntrinsicMethod {
StackValue receiver
) {
JetCallExpression call = (JetCallExpression) element;
ResolvedCall<? extends CallableDescriptor> resolvedCall =
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
ResolvedCall<?> resolvedCall = codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
assert resolvedCall != null;
JetType returnType = resolvedCall.getResultingDescriptor().getReturnType();
assert returnType != null;
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -47,7 +46,7 @@ public class StupidSync extends IntrinsicMethod {
StackValue receiver
) {
assert element != null : "Element should not be null";
ResolvedCall<? extends CallableDescriptor> resolvedCall =
ResolvedCall<?> resolvedCall =
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression());
assert resolvedCall != null : "Resolved call for " + element.getText() + " should be not null";