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(); List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
for (JetAnnotationEntry annotationEntry : annotationEntries) { for (JetAnnotationEntry annotationEntry : annotationEntries) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry); 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 // Is it a "1..2" or so
RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression); RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression);
if (binaryCall != null) { 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 (resolvedCall != null) {
if (RangeCodegenUtil.isOptimizableRangeTo(resolvedCall.getResultingDescriptor())) { if (RangeCodegenUtil.isOptimizableRangeTo(resolvedCall.getResultingDescriptor())) {
generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall)); generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
@@ -1625,7 +1625,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override @Override
public StackValue visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression, StackValue receiver) { 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; DeclarationDescriptor descriptor;
if (resolvedCall == null) { if (resolvedCall == null) {
@@ -1894,7 +1894,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetExpression callee = expression.getCalleeExpression(); JetExpression callee = expression.getCalleeExpression();
assert callee != null; assert callee != null;
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee); ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
if (resolvedCall == null) { if (resolvedCall == null) {
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression); 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); return invokeFunction(call, receiver, resolvedCall);
} }
private StackValue invokeSamConstructor( @NotNull
JetCallExpression expression, private StackValue invokeSamConstructor(JetCallExpression expression, ResolvedCall<?> resolvedCall, JavaClassDescriptor samInterface) {
ResolvedCall<? extends CallableDescriptor> resolvedCall,
JavaClassDescriptor samInterface
) {
List<ResolvedValueArgument> arguments = resolvedCall.getValueArgumentsByIndex(); List<ResolvedValueArgument> arguments = resolvedCall.getValueArgumentsByIndex();
if (arguments == null) { if (arguments == null) {
throw new IllegalStateException("Failed to arrange value arguments by index: " + resolvedCall.getResultingDescriptor()); 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 @NotNull
public StackValue invokeFunction( public StackValue invokeFunction(Call call, StackValue receiver, ResolvedCall<?> resolvedCall) {
Call call,
StackValue receiver,
ResolvedCall<? extends CallableDescriptor> resolvedCall
) {
if (resolvedCall instanceof VariableAsFunctionResolvedCall) { if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return invokeFunction(call, receiver, ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall()); return invokeFunction(call, receiver, ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall());
} }
@@ -2034,7 +2027,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private StackValue invokeFunctionWithCalleeOnStack( private StackValue invokeFunctionWithCalleeOnStack(
@NotNull Call call, @NotNull Call call,
@NotNull StackValue receiver, @NotNull StackValue receiver,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall, @NotNull ResolvedCall<?> resolvedCall,
@NotNull Callable callable @NotNull Callable callable
) { ) {
if (callable instanceof CallableMethod) { if (callable instanceof CallableMethod) {
@@ -2118,7 +2111,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
public void invokeMethodWithArguments( public void invokeMethodWithArguments(
@Nullable Call call, @Nullable Call call,
@NotNull CallableMethod callableMethod, @NotNull CallableMethod callableMethod,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall, @NotNull ResolvedCall<?> resolvedCall,
@NotNull StackValue receiver @NotNull StackValue receiver
) { ) {
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor(); CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
@@ -2159,11 +2152,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
callGenerator.genCall(callable, resolvedCall, mask, this); callGenerator.genCall(callable, resolvedCall, mask, this);
} }
private void genThisAndReceiverFromResolvedCall( private void genThisAndReceiverFromResolvedCall(StackValue receiver, ResolvedCall<?> resolvedCall, CallableMethod callableMethod) {
StackValue receiver,
ResolvedCall<? extends CallableDescriptor> resolvedCall,
CallableMethod callableMethod
) {
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod); receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod);
receiver.put(receiver.type, v); receiver.put(receiver.type, v);
} }
@@ -2461,7 +2450,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression); FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression);
assert functionDescriptor != null : "Callable reference is not resolved to descriptor: " + expression.getText(); 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(); assert resolvedCall != null : "Callable reference is not resolved: " + functionDescriptor + " " + expression.getText();
JetType kFunctionType = bindingContext.get(EXPRESSION_TYPE, expression); 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 static class CallableReferenceGenerationStrategy extends FunctionGenerationStrategy.CodegenBased<FunctionDescriptor> {
private final ResolvedCall<? extends CallableDescriptor> resolvedCall; private final ResolvedCall<?> resolvedCall;
private final FunctionDescriptor referencedFunction; private final FunctionDescriptor referencedFunction;
public CallableReferenceGenerationStrategy( public CallableReferenceGenerationStrategy(
@NotNull GenerationState state, @NotNull GenerationState state,
@NotNull FunctionDescriptor functionDescriptor, @NotNull FunctionDescriptor functionDescriptor,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall @NotNull ResolvedCall<?> resolvedCall
) { ) {
super(state, functionDescriptor); super(state, functionDescriptor);
this.resolvedCall = resolvedCall; 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); return generateIn(StackValue.expression(Type.INT_TYPE, expression.getLeft(), this), expression.getRight(), reference);
} }
else { 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); Call call = bindingContext.get(BindingContext.CALL, reference);
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, reference); DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, reference);
@@ -2912,8 +2901,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
gen(right, type); gen(right, type);
} }
else { else {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
Call call = bindingContext.get(BindingContext.CALL, expression.getOperationReference()); Call call = bindingContext.get(BindingContext.CALL, expression.getOperationReference());
StackValue result = invokeFunction(call, receiver, resolvedCall); StackValue result = invokeFunction(call, receiver, resolvedCall);
type = Type.INT_TYPE; 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) { private void callAugAssignMethod(JetBinaryExpression expression, CallableMethod callable, Type lhsType, boolean keepReturnValue) {
JetSimpleNameExpression reference = expression.getOperationReference(); JetSimpleNameExpression reference = expression.getOperationReference();
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, reference);
bindingContext.get(BindingContext.RESOLVED_CALL, reference);
Call call = bindingContext.get(BindingContext.CALL, reference); Call call = bindingContext.get(BindingContext.CALL, reference);
assert resolvedCall != null : "Resolved call should be not null for operation reference in " + expression.getText(); 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(); DeclarationDescriptor cls = op.getContainingDeclaration();
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null; assert resolvedCall != null;
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) { 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; storeType = type;
} }
else { else {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference()); ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null; assert resolvedCall != null;
Callable callable = resolveToCallable((FunctionDescriptor) op, false); Callable callable = resolveToCallable((FunctionDescriptor) op, false);
CallableMethod callableMethod = (CallableMethod) callable; CallableMethod callableMethod = (CallableMethod) callable;
@@ -3273,7 +3259,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull @NotNull
private StackValue generateNewCall( private StackValue generateNewCall(
@NotNull JetCallExpression expression, @NotNull JetCallExpression expression,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall, @NotNull ResolvedCall<?> resolvedCall,
@NotNull StackValue receiver @NotNull StackValue receiver
) { ) {
Type type = expressionType(expression); Type type = expressionType(expression);
@@ -3286,11 +3272,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
} }
@NotNull @NotNull
private StackValue generateConstructorCall( private StackValue generateConstructorCall(@NotNull ResolvedCall<?> resolvedCall, @NotNull StackValue receiver, @NotNull Type type) {
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull StackValue receiver,
@NotNull Type type
) {
v.anew(type); v.anew(type);
v.dup(); 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) { private void invokeFunctionByReference(JetSimpleNameExpression operationReference) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(RESOLVED_CALL, operationReference);
bindingContext.get(RESOLVED_CALL, operationReference);
Call call = bindingContext.get(CALL, operationReference); Call call = bindingContext.get(CALL, operationReference);
invokeFunction(call, StackValue.none(), resolvedCall); invokeFunction(call, StackValue.none(), resolvedCall);
} }
@@ -1322,7 +1322,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression(); JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
PropertyDescriptor propertyDescriptor = null; PropertyDescriptor propertyDescriptor = null;
if (expression instanceof JetSimpleNameExpression) { 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) { if (call != null) {
CallableDescriptor callResultingDescriptor = call.getResultingDescriptor(); CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
if (callResultingDescriptor instanceof ValueParameterDescriptor) { if (callResultingDescriptor instanceof ValueParameterDescriptor) {
@@ -1549,8 +1549,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor); CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor);
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, ((JetCallElement) superCall).getCalleeExpression());
bindingContext.get(BindingContext.RESOLVED_CALL, ((JetCallElement) superCall).getCalleeExpression());
assert resolvedCall != null; assert resolvedCall != null;
ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor(); ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
@@ -1651,7 +1650,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
throw new UnsupportedOperationException("unsupported type of enum constant initializer: " + specifier); throw new UnsupportedOperationException("unsupported type of enum constant initializer: " + specifier);
} }
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, ((JetDelegatorToSuperCall) specifier).getCalleeExpression()); bindingContext.get(BindingContext.RESOLVED_CALL, ((JetDelegatorToSuperCall) specifier).getCalleeExpression());
assert resolvedCall != null : "Enum entry delegation specifier is unresolved: " + specifier.getText(); 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.Type;
import org.jetbrains.asm4.commons.InstructionAdapter; import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.asm4.commons.Method; import org.jetbrains.asm4.commons.Method;
import org.jetbrains.asm4.tree.MethodNode;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod; import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapper; import org.jetbrains.jet.codegen.state.JetTypeMapper;
@@ -326,7 +325,7 @@ public abstract class StackValue {
} }
public static StackValue receiver( public static StackValue receiver(
ResolvedCall<? extends CallableDescriptor> resolvedCall, ResolvedCall<?> resolvedCall,
StackValue receiver, StackValue receiver,
ExpressionCodegen codegen, ExpressionCodegen codegen,
@Nullable CallableMethod callableMethod @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) { if (call == null) {
return true; return true;
} }
@@ -1099,14 +1098,14 @@ public abstract class StackValue {
} }
public static class CallReceiver extends StackValue { public static class CallReceiver extends StackValue {
private final ResolvedCall<? extends CallableDescriptor> resolvedCall; private final ResolvedCall<?> resolvedCall;
final StackValue receiver; final StackValue receiver;
private final ExpressionCodegen codegen; private final ExpressionCodegen codegen;
private final CallableMethod callableMethod; private final CallableMethod callableMethod;
private final boolean putReceiverArgumentOnStack; private final boolean putReceiverArgumentOnStack;
public CallReceiver( public CallReceiver(
ResolvedCall<? extends CallableDescriptor> resolvedCall, ResolvedCall<?> resolvedCall,
StackValue receiver, StackValue receiver,
ExpressionCodegen codegen, ExpressionCodegen codegen,
CallableMethod callableMethod, CallableMethod callableMethod,
@@ -1120,11 +1119,7 @@ public abstract class StackValue {
this.putReceiverArgumentOnStack = putReceiverArgumentOnStack; this.putReceiverArgumentOnStack = putReceiverArgumentOnStack;
} }
private static Type calcType( private static Type calcType(ResolvedCall<?> resolvedCall, ExpressionCodegen codegen, CallableMethod callableMethod) {
ResolvedCall<? extends CallableDescriptor> resolvedCall,
ExpressionCodegen codegen,
CallableMethod callableMethod
) {
ReceiverValue thisObject = resolvedCall.getThisObject(); ReceiverValue thisObject = resolvedCall.getThisObject();
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument(); ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
@@ -64,7 +64,7 @@ public class TailRecursionCodegen {
return status != null && status.isDoGenerateTailRecursion(); return status != null && status.isDoGenerateTailRecursion();
} }
public void generateTailRecursion(ResolvedCall<? extends CallableDescriptor> resolvedCall) { public void generateTailRecursion(ResolvedCall<?> resolvedCall) {
CallableDescriptor fd = resolvedCall.getResultingDescriptor(); CallableDescriptor fd = resolvedCall.getResultingDescriptor();
assert fd instanceof FunctionDescriptor : "Resolved call doesn't refer to the function descriptor: " + fd; assert fd instanceof FunctionDescriptor : "Resolved call doesn't refer to the function descriptor: " + fd;
CallableMethod callable = (CallableMethod) codegen.resolveToCallable((FunctionDescriptor) fd, false); CallableMethod callable = (CallableMethod) codegen.resolveToCallable((FunctionDescriptor) fd, false);
@@ -107,7 +107,7 @@ public class TailRecursionCodegen {
JetExpression argumentExpression = argument == null ? null : argument.getArgumentExpression(); JetExpression argumentExpression = argument == null ? null : argument.getArgumentExpression();
if (argumentExpression instanceof JetSimpleNameExpression) { 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())) { if (resolvedCall != null && resolvedCall.getResultingDescriptor().equals(parameterDescriptor.getOriginal())) {
// do nothing: we shouldn't store argument to itself again // do nothing: we shouldn't store argument to itself again
AsmUtil.pop(v, type); AsmUtil.pop(v, type);
@@ -314,8 +314,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
// working around a problem with shallow analysis // working around a problem with shallow analysis
if (functionDescriptor == null) return; if (functionDescriptor == null) return;
ResolvedCall<? extends CallableDescriptor> referencedFunction = ResolvedCall<?> referencedFunction = bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
bindingContext.get(RESOLVED_CALL, expression.getCallableReference());
if (referencedFunction == null) return; if (referencedFunction == null) return;
JetType superType = getSuperTypeForClosure((FunctionDescriptor) referencedFunction.getResultingDescriptor(), true); JetType superType = getSuperTypeForClosure((FunctionDescriptor) referencedFunction.getResultingDescriptor(), true);
@@ -406,7 +405,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
@Override @Override
public void visitCallExpression(@NotNull JetCallExpression expression) { public void visitCallExpression(@NotNull JetCallExpression expression) {
super.visitCallExpression(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) { if (call == null) {
return; return;
} }
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter; import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; 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.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.psi.JetCallExpression; import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
@@ -46,7 +45,7 @@ public class JavaClassArray extends IntrinsicMethod {
@Nullable List<JetExpression> arguments, @Nullable List<JetExpression> arguments,
StackValue receiver StackValue receiver
) { ) {
ResolvedCall<? extends CallableDescriptor> call = ResolvedCall<?> call =
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression()); codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression());
assert call != null; assert call != null;
Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> next = call.getValueArguments().entrySet().iterator().next(); 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.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; 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.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -48,8 +47,7 @@ public class JavaClassFunction extends IntrinsicMethod {
StackValue receiver StackValue receiver
) { ) {
JetCallExpression call = (JetCallExpression) element; JetCallExpression call = (JetCallExpression) element;
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
assert resolvedCall != null; assert resolvedCall != null;
JetType returnType = resolvedCall.getResultingDescriptor().getReturnType(); JetType returnType = resolvedCall.getResultingDescriptor().getReturnType();
assert returnType != null; assert returnType != null;
@@ -23,7 +23,6 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter; import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; 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.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -47,7 +46,7 @@ public class StupidSync extends IntrinsicMethod {
StackValue receiver StackValue receiver
) { ) {
assert element != null : "Element should not be null"; assert element != null : "Element should not be null";
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall =
codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression()); codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, ((JetCallExpression) element).getCalleeExpression());
assert resolvedCall != null : "Resolved call for " + element.getText() + " should be not null"; assert resolvedCall != null : "Resolved call for " + element.getText() + " should be not null";
@@ -377,7 +377,7 @@ public interface Errors {
DiagnosticFactory0<JetMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT); DiagnosticFactory0<JetMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
DiagnosticFactory2<JetExpression, Name, JetType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT); DiagnosticFactory2<JetExpression, Name, JetType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory2<JetExpression, Name, Collection<? extends ResolvedCall<? extends CallableDescriptor>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT); DiagnosticFactory2<JetExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory3<JetExpression, Name, JetType, JetType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT); DiagnosticFactory3<JetExpression, Name, JetType, JetType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
// Super calls // Super calls
@@ -106,12 +106,12 @@ public class Renderers {
}; };
public static final Renderer<Collection<? extends ResolvedCall<?>>> AMBIGUOUS_CALLS = public static final Renderer<Collection<? extends ResolvedCall<?>>> AMBIGUOUS_CALLS =
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() { new Renderer<Collection<? extends ResolvedCall<?>>>() {
@NotNull @NotNull
@Override @Override
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> argument) { public String render(@NotNull Collection<? extends ResolvedCall<?>> argument) {
StringBuilder stringBuilder = new StringBuilder("\n"); StringBuilder stringBuilder = new StringBuilder("\n");
for (ResolvedCall<? extends CallableDescriptor> call : argument) { for (ResolvedCall<?> call : argument) {
stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n"); stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n");
} }
return stringBuilder.toString(); return stringBuilder.toString();
@@ -208,11 +208,10 @@ public class AnnotationResolver {
public static void resolveAnnotationArgument( public static void resolveAnnotationArgument(
@NotNull AnnotationDescriptorImpl annotationDescriptor, @NotNull AnnotationDescriptorImpl annotationDescriptor,
@NotNull ResolvedCall<? extends CallableDescriptor> call, @NotNull ResolvedCall<?> resolvedCall,
@NotNull BindingTrace trace @NotNull BindingTrace trace
) { ) {
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> descriptorToArgument : for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> descriptorToArgument : resolvedCall.getValueArguments().entrySet()) {
call.getValueArguments().entrySet()) {
ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey(); ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey();
JetType varargElementType = parameterDescriptor.getVarargElementType(); JetType varargElementType = parameterDescriptor.getVarargElementType();
@@ -88,8 +88,7 @@ public interface BindingContext {
new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING); new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
@KotlinSignature("val RESOLVED_CALL: WritableSlice<JetElement, ResolvedCall<out CallableDescriptor>>") @KotlinSignature("val RESOLVED_CALL: WritableSlice<JetElement, ResolvedCall<out CallableDescriptor>>")
WritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>> RESOLVED_CALL = WritableSlice<JetElement, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<JetElement, ResolvedCall<?>>(DO_NOTHING);
new BasicWritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>>(DO_NOTHING);
WritableSlice<ResolvedCall<?>, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice(); WritableSlice<ResolvedCall<?>, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice();
WritableSlice<JetElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<JetElement, ConstraintSystemCompleter>(DO_NOTHING); WritableSlice<JetElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<JetElement, ConstraintSystemCompleter>(DO_NOTHING);
WritableSlice<JetElement, Call> CALL = new BasicWritableSlice<JetElement, Call>(DO_NOTHING); WritableSlice<JetElement, Call> CALL = new BasicWritableSlice<JetElement, Call>(DO_NOTHING);
@@ -39,9 +39,7 @@ import java.util.*;
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.*; import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.*;
import static org.jetbrains.jet.lang.diagnostics.Errors.AMBIGUOUS_LABEL; import static org.jetbrains.jet.lang.diagnostics.Errors.AMBIGUOUS_LABEL;
import static org.jetbrains.jet.lang.resolve.BindingContext.AMBIGUOUS_LABEL_TARGET; import static org.jetbrains.jet.lang.resolve.BindingContext.*;
import static org.jetbrains.jet.lang.resolve.BindingContext.CAPTURED_IN_CLOSURE;
import static org.jetbrains.jet.lang.resolve.BindingContext.DECLARATION_TO_DESCRIPTOR;
public class BindingContextUtils { public class BindingContextUtils {
private BindingContextUtils() { private BindingContextUtils() {
@@ -302,7 +300,7 @@ public class BindingContextUtils {
) { ) {
if (expression instanceof JetCallExpression) { if (expression instanceof JetCallExpression) {
JetExpression calleeExpression = ((JetCallExpression) expression).getCalleeExpression(); JetExpression calleeExpression = ((JetCallExpression) expression).getCalleeExpression();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, calleeExpression); ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, calleeExpression);
if (resolvedCall instanceof VariableAsFunctionResolvedCall) { if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return true; return true;
} }
@@ -112,11 +112,11 @@ public class CompileTimeConstantUtils {
return value instanceof String ? (String) value : null; return value instanceof String ? (String) value : null;
} }
public static boolean isArrayMethodCall(@NotNull ResolvedCall resolvedCall) { public static boolean isArrayMethodCall(@NotNull ResolvedCall<?> resolvedCall) {
return "kotlin.arrays.array".equals(getIntrinsicAnnotationArgument(resolvedCall.getResultingDescriptor().getOriginal())); return "kotlin.arrays.array".equals(getIntrinsicAnnotationArgument(resolvedCall.getResultingDescriptor().getOriginal()));
} }
public static boolean isJavaClassMethodCall(@NotNull ResolvedCall resolvedCall) { public static boolean isJavaClassMethodCall(@NotNull ResolvedCall<?> resolvedCall) {
return "kotlin.javaClass.function".equals(getIntrinsicAnnotationArgument(resolvedCall.getResultingDescriptor().getOriginal())); return "kotlin.javaClass.function".equals(getIntrinsicAnnotationArgument(resolvedCall.getResultingDescriptor().getOriginal()));
} }
@@ -399,8 +399,12 @@ public class CallExpressionResolver {
return false; return false;
} }
private void checkSuper(@NotNull ReceiverValue receiverValue, @NotNull OverloadResolutionResults<? extends CallableDescriptor> results, private static void checkSuper(
@NotNull BindingTrace trace, @NotNull JetExpression expression) { @NotNull ReceiverValue receiverValue,
@NotNull OverloadResolutionResults<?> results,
@NotNull BindingTrace trace,
@NotNull JetExpression expression
) {
if (!results.isSingleResult()) return; if (!results.isSingleResult()) return;
if (!(receiverValue instanceof ExpressionReceiver)) return; if (!(receiverValue instanceof ExpressionReceiver)) return;
JetExpression receiver = ((ExpressionReceiver) receiverValue).getExpression(); JetExpression receiver = ((ExpressionReceiver) receiverValue).getExpression();
@@ -27,7 +27,10 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.*;
import org.jetbrains.jet.lang.resolve.calls.autocasts.*; import org.jetbrains.jet.lang.resolve.calls.autocasts.AutoCastUtils;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValueFactory;
import org.jetbrains.jet.lang.resolve.calls.context.*; import org.jetbrains.jet.lang.resolve.calls.context.*;
import org.jetbrains.jet.lang.resolve.calls.inference.*; import org.jetbrains.jet.lang.resolve.calls.inference.*;
import org.jetbrains.jet.lang.resolve.calls.model.*; import org.jetbrains.jet.lang.resolve.calls.model.*;
@@ -347,8 +350,7 @@ public class CandidateResolver {
context = context.replaceExpectedType(expectedType); context = context.replaceExpectedType(expectedType);
JetExpression keyExpression = getDeferredComputationKeyExpression(expression); JetExpression keyExpression = getDeferredComputationKeyExpression(expression);
CallCandidateResolutionContext<? extends CallableDescriptor> storedContextForArgument = CallCandidateResolutionContext<?> storedContextForArgument = context.resolutionResultsCache.getDeferredComputation(keyExpression);
context.resolutionResultsCache.getDeferredComputation(keyExpression);
PsiElement parent = expression.getParent(); PsiElement parent = expression.getParent();
if (parent instanceof JetWhenExpression && expression == ((JetWhenExpression) parent).getSubjectExpression() if (parent instanceof JetWhenExpression && expression == ((JetWhenExpression) parent).getSubjectExpression()
@@ -361,7 +363,7 @@ public class CandidateResolver {
return; return;
} }
CallCandidateResolutionContext<? extends CallableDescriptor> contextForArgument = storedContextForArgument CallCandidateResolutionContext<?> contextForArgument = storedContextForArgument
.replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType); .replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType);
JetType type; JetType type;
if (contextForArgument.candidateCall.hasIncompleteTypeParameters() if (contextForArgument.candidateCall.hasIncompleteTypeParameters()
@@ -405,32 +407,27 @@ public class CandidateResolver {
JetExpression keyExpression = getDeferredComputationKeyExpression(expression); JetExpression keyExpression = getDeferredComputationKeyExpression(expression);
markResultingCallAsCompleted(context, keyExpression); markResultingCallAsCompleted(context, keyExpression);
CallCandidateResolutionContext<? extends CallableDescriptor> storedContextForArgument = CallCandidateResolutionContext<?> storedContextForArgument =
context.resolutionResultsCache.getDeferredComputation(keyExpression); context.resolutionResultsCache.getDeferredComputation(keyExpression);
if (storedContextForArgument != null) { if (storedContextForArgument != null) {
completeNestedCallsForNotResolvedInvocation(storedContextForArgument); completeNestedCallsForNotResolvedInvocation(storedContextForArgument);
CallCandidateResolutionContext<? extends CallableDescriptor> newContext = CallCandidateResolutionContext<?> newContext = storedContextForArgument.replaceBindingTrace(context.trace);
storedContextForArgument.replaceBindingTrace(context.trace);
completeUnmappedArguments(newContext, storedContextForArgument.candidateCall.getUnmappedArguments()); completeUnmappedArguments(newContext, storedContextForArgument.candidateCall.getUnmappedArguments());
argumentTypeResolver.checkTypesForFunctionArgumentsWithNoCallee(newContext.replaceContextDependency(INDEPENDENT)); argumentTypeResolver.checkTypesForFunctionArgumentsWithNoCallee(newContext.replaceContextDependency(INDEPENDENT));
} }
} }
} }
private static void markResultingCallAsCompleted( private static void markResultingCallAsCompleted(@NotNull CallResolutionContext<?> context, @Nullable JetExpression keyExpression) {
@NotNull CallResolutionContext<?> context,
@Nullable JetExpression keyExpression
) {
if (keyExpression == null) return; if (keyExpression == null) return;
CallCandidateResolutionContext<? extends CallableDescriptor> storedContextForArgument = CallCandidateResolutionContext<?> storedContextForArgument = context.resolutionResultsCache.getDeferredComputation(keyExpression);
context.resolutionResultsCache.getDeferredComputation(keyExpression);
if (storedContextForArgument == null) return; if (storedContextForArgument == null) return;
storedContextForArgument.candidateCall.markCallAsCompleted(); storedContextForArgument.candidateCall.markCallAsCompleted();
// clean data for "invoke" calls // clean data for "invoke" calls
ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall = context.resolutionResultsCache.getCallForArgument(keyExpression); ResolvedCallWithTrace<?> resolvedCall = context.resolutionResultsCache.getCallForArgument(keyExpression);
assert resolvedCall != null : "Resolved call for '" + keyExpression + "' is not stored, but CallCandidateResolutionContext is."; assert resolvedCall != null : "Resolved call for '" + keyExpression + "' is not stored, but CallCandidateResolutionContext is.";
resolvedCall.markCallAsCompleted(); resolvedCall.markCallAsCompleted();
} }
@@ -70,9 +70,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
} }
@Override @Override
public <F extends CallableDescriptor> void run( public <F extends CallableDescriptor> void run(@NotNull ResolvedCall<F> resolvedCall, @NotNull BasicCallResolutionContext context) {
@NotNull ResolvedCall<F> resolvedCall, @NotNull BasicCallResolutionContext context
) {
JetExpression expression = context.call.getCalleeExpression(); JetExpression expression = context.call.getCalleeExpression();
if (expression == null) { if (expression == null) {
return; return;
@@ -186,7 +184,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
@NotNull BasicCallResolutionContext context, @NotNull BasicCallResolutionContext context,
@NotNull JetExpression expression @NotNull JetExpression expression
) { ) {
ResolvedCall<? extends CallableDescriptor> thisCall = context.trace.get(BindingContext.RESOLVED_CALL, expression); ResolvedCall<?> thisCall = context.trace.get(BindingContext.RESOLVED_CALL, expression);
return thisCall != null ? thisCall.getResultingDescriptor() : null; return thisCall != null ? thisCall.getResultingDescriptor() : null;
} }
@@ -62,8 +62,8 @@ public interface ResolutionResultsCache {
); );
@Nullable @Nullable
CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression); CallCandidateResolutionContext<?> getDeferredComputation(@Nullable JetExpression expression);
@Nullable @Nullable
ResolvedCallWithTrace<? extends CallableDescriptor> getCallForArgument(@Nullable JetExpression expression); ResolvedCallWithTrace<?> getCallForArgument(@Nullable JetExpression expression);
} }
@@ -36,12 +36,11 @@ import static org.jetbrains.jet.lang.psi.Call.CallType;
import static org.jetbrains.jet.lang.psi.Call.CallType.*; import static org.jetbrains.jet.lang.psi.Call.CallType.*;
public class ResolutionResultsCacheImpl implements ResolutionResultsCache { public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<FunctionDescriptor>> public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<FunctionDescriptor>> RESOLUTION_RESULTS_FOR_FUNCTION = Slices.createSimpleSlice();
RESOLUTION_RESULTS_FOR_FUNCTION = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<VariableDescriptor>> RESOLUTION_RESULTS_FOR_PROPERTY = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<VariableDescriptor>> RESOLUTION_RESULTS_FOR_PROPERTY = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, CallCandidateResolutionContext<? extends CallableDescriptor>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, CallCandidateResolutionContext<?>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
public static final WritableSlice<CallKey, ResolvedCallWithTrace<? extends CallableDescriptor>> RESOLVED_CALL_FOR_ARGUMENT = Slices.createSimpleSlice(); public static final WritableSlice<CallKey, ResolvedCallWithTrace<?>> RESOLVED_CALL_FOR_ARGUMENT = Slices.createSimpleSlice();
static { static {
BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class); BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class);
@@ -91,7 +90,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
@Override @Override
@Nullable @Nullable
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) { public CallCandidateResolutionContext<?> getDeferredComputation(@Nullable JetExpression expression) {
return getValueTryingAllCallTypes(expression, DEFERRED_COMPUTATION_FOR_CALL); return getValueTryingAllCallTypes(expression, DEFERRED_COMPUTATION_FOR_CALL);
} }
@@ -113,7 +112,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
@Nullable @Nullable
@Override @Override
public ResolvedCallWithTrace<? extends CallableDescriptor> getCallForArgument(@Nullable JetExpression expression) { public ResolvedCallWithTrace<?> getCallForArgument(@Nullable JetExpression expression) {
return getValueTryingAllCallTypes(expression, RESOLVED_CALL_FOR_ARGUMENT); return getValueTryingAllCallTypes(expression, RESOLVED_CALL_FOR_ARGUMENT);
} }
@@ -85,8 +85,8 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
@Nullable @Nullable
@Override @Override
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) { public CallCandidateResolutionContext<?> getDeferredComputation(@Nullable JetExpression expression) {
CallCandidateResolutionContext<? extends CallableDescriptor> computation = innerCache.getDeferredComputation(expression); CallCandidateResolutionContext<?> computation = innerCache.getDeferredComputation(expression);
if (computation != null) { if (computation != null) {
return computation; return computation;
} }
@@ -95,8 +95,8 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
@Nullable @Nullable
@Override @Override
public ResolvedCallWithTrace<? extends CallableDescriptor> getCallForArgument(@Nullable JetExpression expression) { public ResolvedCallWithTrace<?> getCallForArgument(@Nullable JetExpression expression) {
ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall = innerCache.getCallForArgument(expression); ResolvedCallWithTrace<?> resolvedCall = innerCache.getCallForArgument(expression);
if (resolvedCall != null) { if (resolvedCall != null) {
return resolvedCall; return resolvedCall;
} }
@@ -45,16 +45,16 @@ import static org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus.UNKN
public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedCallWithTrace<D> { public class ResolvedCallImpl<D extends CallableDescriptor> implements ResolvedCallWithTrace<D> {
public static final Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor>() { public static final Function<ResolvedCallWithTrace<?>, CallableDescriptor> MAP_TO_CANDIDATE = new Function<ResolvedCallWithTrace<?>, CallableDescriptor>() {
@Override @Override
public CallableDescriptor fun(ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall) { public CallableDescriptor fun(ResolvedCallWithTrace<?> resolvedCall) {
return resolvedCall.getCandidateDescriptor(); return resolvedCall.getCandidateDescriptor();
} }
}; };
public static final Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCallWithTrace<? extends CallableDescriptor>, CallableDescriptor>() { public static final Function<ResolvedCallWithTrace<?>, CallableDescriptor> MAP_TO_RESULT = new Function<ResolvedCallWithTrace<?>, CallableDescriptor>() {
@Override @Override
public CallableDescriptor fun(ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall) { public CallableDescriptor fun(ResolvedCallWithTrace<?> resolvedCall) {
return resolvedCall.getResultingDescriptor(); return resolvedCall.getResultingDescriptor();
} }
}; };
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.calls.results;
import com.intellij.openapi.application.Application; import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.resolve.calls.inference.BoundsOwner; import org.jetbrains.jet.lang.resolve.calls.inference.BoundsOwner;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
@@ -27,18 +26,17 @@ import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.util.slicedmap.*; import org.jetbrains.jet.util.slicedmap.*;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ResolutionDebugInfo { public class ResolutionDebugInfo {
public static final WritableSlice<One, List<? extends ResolutionTask<? extends CallableDescriptor, ?>>> TASKS = Slices.createSimpleSlice(); public static final WritableSlice<One, List<? extends ResolutionTask<?, ?>>> TASKS = Slices.createSimpleSlice();
public static final WritableSlice<One, ResolvedCall<? extends CallableDescriptor>> RESULT = Slices.createSimpleSlice(); public static final WritableSlice<One, ResolvedCall<?>> RESULT = Slices.createSimpleSlice();
public static final WritableSlice<ResolvedCall<? extends CallableDescriptor>, StringBuilder> ERRORS = Slices.createSimpleSlice(); public static final WritableSlice<ResolvedCall<?>, StringBuilder> ERRORS = Slices.createSimpleSlice();
public static final WritableSlice<ResolvedCall<? extends CallableDescriptor>, StringBuilder> LOG = Slices.createSimpleSlice(); public static final WritableSlice<ResolvedCall<?>, StringBuilder> LOG = Slices.createSimpleSlice();
public static final WritableSlice<ResolvedCall<? extends CallableDescriptor>, Map<TypeParameterDescriptor, BoundsOwner>> BOUNDS_FOR_UNKNOWNS = Slices.createSimpleSlice(); public static final WritableSlice<ResolvedCall<?>, Map<TypeParameterDescriptor, BoundsOwner>> BOUNDS_FOR_UNKNOWNS = Slices.createSimpleSlice();
public static final WritableSlice<ResolvedCall<? extends CallableDescriptor>, Map<JetType, BoundsOwner>> BOUNDS_FOR_KNOWNS = Slices.createSimpleSlice(); public static final WritableSlice<ResolvedCall<?>, Map<JetType, BoundsOwner>> BOUNDS_FOR_KNOWNS = Slices.createSimpleSlice();
public static boolean RESOLUTION_DEBUG_INFO_ENABLED = false; public static boolean RESOLUTION_DEBUG_INFO_ENABLED = false;
@@ -153,12 +153,12 @@ public class ExpressionTypingUtils {
return false; return false;
} }
ResolvedCall<? extends CallableDescriptor> call = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression()); ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
if (call == null) { if (resolvedCall == null) {
return false; return false;
} }
CallableDescriptor callable = call.getResultingDescriptor(); CallableDescriptor callable = resolvedCall.getResultingDescriptor();
if (callable instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) callable).getInlineStrategy().isInline()) { if (callable instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) callable).getInlineStrategy().isInline()) {
DeclarationDescriptor scopeContainerParent = scopeContainer.getContainingDeclaration(); DeclarationDescriptor scopeContainerParent = scopeContainer.getContainingDeclaration();
assert scopeContainerParent != null : "parent is null for " + scopeContainer; assert scopeContainerParent != null : "parent is null for " + scopeContainer;
@@ -25,7 +25,6 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.evaluate.EvaluatePackage;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.*;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
@@ -273,8 +272,8 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
OverloadResolutionResults<FunctionDescriptor> ambiguityResolutionResults = OverloadResolutionResultsUtil.ambiguity(assignmentOperationDescriptors, binaryOperationDescriptors); OverloadResolutionResults<FunctionDescriptor> ambiguityResolutionResults = OverloadResolutionResultsUtil.ambiguity(assignmentOperationDescriptors, binaryOperationDescriptors);
context.trace.report(ASSIGN_OPERATOR_AMBIGUITY.on(operationSign, ambiguityResolutionResults.getResultingCalls())); context.trace.report(ASSIGN_OPERATOR_AMBIGUITY.on(operationSign, ambiguityResolutionResults.getResultingCalls()));
Collection<DeclarationDescriptor> descriptors = Sets.newHashSet(); Collection<DeclarationDescriptor> descriptors = Sets.newHashSet();
for (ResolvedCall<? extends FunctionDescriptor> call : ambiguityResolutionResults.getResultingCalls()) { for (ResolvedCall<?> resolvedCall : ambiguityResolutionResults.getResultingCalls()) {
descriptors.add(call.getResultingDescriptor()); descriptors.add(resolvedCall.getResultingDescriptor());
} }
dataFlowInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo)).getDataFlowInfo(); dataFlowInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo)).getDataFlowInfo();
context.trace.record(AMBIGUOUS_REFERENCE_TARGET, operationSign, descriptors); context.trace.record(AMBIGUOUS_REFERENCE_TARGET, operationSign, descriptors);
@@ -22,7 +22,6 @@ import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport; import org.jetbrains.jet.cli.jvm.compiler.CliLightClassGenerationSupport;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetElement;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
@@ -71,17 +70,16 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
} }
} }
ImmutableMap<JetElement,ResolvedCall<? extends CallableDescriptor>> resolvedCallsEntries = ImmutableMap<JetElement, ResolvedCall<?>> resolvedCallsEntries = bindingContext.getSliceContents(BindingContext.RESOLVED_CALL);
bindingContext.getSliceContents(BindingContext.RESOLVED_CALL); for (Map.Entry<JetElement, ResolvedCall<?>> entry : resolvedCallsEntries.entrySet()) {
for (Map.Entry<JetElement, ResolvedCall<? extends CallableDescriptor>> entry : resolvedCallsEntries.entrySet()) {
JetElement element = entry.getKey(); JetElement element = entry.getKey();
ResolvedCall<? extends CallableDescriptor> resolvedCall = entry.getValue(); ResolvedCall<?> resolvedCall = entry.getValue();
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.LineAndColumn lineAndColumn =
DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange()); DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange());
assertTrue("Resolved call for '" + element.getText() + "'" + lineAndColumn + " in not completed", assertTrue("Resolved call for '" + element.getText() + "'" + lineAndColumn + " in not completed",
((ResolvedCallWithTrace<? extends CallableDescriptor>)resolvedCall).isCompleted()); ((ResolvedCallWithTrace<?>) resolvedCall).isCompleted());
} }
} }
} }
@@ -16,18 +16,12 @@
package org.jetbrains.jet.resolve.calls package org.jetbrains.jet.resolve.calls
import com.google.common.collect.ImmutableMap
import org.jetbrains.annotations.NotNull
import org.jetbrains.jet.ConfigurationKind import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.JetLiteFixture import org.jetbrains.jet.JetLiteFixture
import org.jetbrains.jet.JetTestUtils import org.jetbrains.jet.JetTestUtils
import org.jetbrains.jet.analyzer.AnalyzeExhaust
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
import org.jetbrains.jet.lang.psi.JetElement import org.jetbrains.jet.lang.psi.JetElement
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter
import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind
@@ -54,14 +48,14 @@ public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
} }
val explicitReceiverKind = directives.getExplicitReceiverKind() val explicitReceiverKind = directives.getExplicitReceiverKind()
fun analyzeFileAndGetResolvedCallEntries(): Map<JetElement, ResolvedCall<out CallableDescriptor?>> { fun analyzeFileAndGetResolvedCallEntries(): Map<JetElement, ResolvedCall<*>> {
val psiFile = JetTestUtils.loadJetFile(getProject(), file) val psiFile = JetTestUtils.loadJetFile(getProject(), file)
val analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.emptyList()) val analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.emptyList())
val bindingContext = analyzeExhaust!!.getBindingContext() val bindingContext = analyzeExhaust.getBindingContext()
return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL) return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL)
} }
fun checkResolvedCall(resolvedCall: ResolvedCall<out CallableDescriptor?>, element: JetElement) { fun checkResolvedCall(resolvedCall: ResolvedCall<*>, element: JetElement) {
val lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange()) val lineAndColumn = DiagnosticUtils.getLineAndColumnInPsiFile(element.getContainingFile(), element.getTextRange())
val (actualThisObject, actualReceiverArgument, actualExplicitReceiverKind) = with(resolvedCall) { val (actualThisObject, actualReceiverArgument, actualExplicitReceiverKind) = with(resolvedCall) {
@@ -19,7 +19,10 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils;
@@ -64,8 +67,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
public void visitCallExpression(@NotNull JetCallExpression expression) { public void visitCallExpression(@NotNull JetCallExpression expression) {
JetExpression callee = expression.getCalleeExpression(); JetExpression callee = expression.getCalleeExpression();
if (callee instanceof JetReferenceExpression) { if (callee instanceof JetReferenceExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
bindingContext.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
if (resolvedCall != null) { if (resolvedCall != null) {
DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor(); DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
if (resolvedCall instanceof VariableAsFunctionResolvedCall) { if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
@@ -61,12 +61,12 @@ public class IdeRenderers {
} }
public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_AMBIGUOUS_CALLS = public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_AMBIGUOUS_CALLS =
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() { new Renderer<Collection<? extends ResolvedCall<?>>>() {
@NotNull @NotNull
@Override @Override
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> calls) { public String render(@NotNull Collection<? extends ResolvedCall<?>> calls) {
StringBuilder stringBuilder = new StringBuilder(""); StringBuilder stringBuilder = new StringBuilder("");
for (ResolvedCall<? extends CallableDescriptor> call : calls) { for (ResolvedCall<?> call : calls) {
stringBuilder.append("<li>"); stringBuilder.append("<li>");
stringBuilder.append(DescriptorRenderer.HTML.render(call.getResultingDescriptor())); stringBuilder.append(DescriptorRenderer.HTML.render(call.getResultingDescriptor()));
stringBuilder.append("</li>"); stringBuilder.append("</li>");
@@ -84,11 +84,9 @@ public class IdeRenderers {
}; };
public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_NONE_APPLICABLE_CALLS = public static final Renderer<Collection<? extends ResolvedCall<?>>> HTML_NONE_APPLICABLE_CALLS =
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() { new Renderer<Collection<? extends ResolvedCall<?>>>() {
@Nullable @Nullable
private ValueParameterDescriptor findParameterByArgumentExpression( private ValueParameterDescriptor findParameterByArgumentExpression(ResolvedCall<?> call, JetValueArgument argument) {
ResolvedCall<? extends CallableDescriptor> call,
JetValueArgument argument) {
for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) { for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : call.getValueArguments().entrySet()) {
for (ValueArgument va : entry.getValue().getArguments()) { for (ValueArgument va : entry.getValue().getArguments()) {
if (va == argument) { if (va == argument) {
@@ -99,7 +97,7 @@ public class IdeRenderers {
return null; return null;
} }
private Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<? extends CallableDescriptor> call) { private Set<ValueParameterDescriptor> getParametersToHighlight(ResolvedCall<?> call) {
Set<ValueParameterDescriptor> parameters = new HashSet<ValueParameterDescriptor>(); Set<ValueParameterDescriptor> parameters = new HashSet<ValueParameterDescriptor>();
if (call instanceof ResolvedCallImpl) { if (call instanceof ResolvedCallImpl) {
Iterable<Diagnostic> diagnostics = ((ResolvedCallImpl)call).getTrace().getBindingContext().getDiagnostics(); Iterable<Diagnostic> diagnostics = ((ResolvedCallImpl)call).getTrace().getBindingContext().getDiagnostics();
@@ -126,9 +124,9 @@ public class IdeRenderers {
@NotNull @NotNull
@Override @Override
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> calls) { public String render(@NotNull Collection<? extends ResolvedCall<?>> calls) {
StringBuilder stringBuilder = new StringBuilder(""); StringBuilder stringBuilder = new StringBuilder("");
for (ResolvedCall<? extends CallableDescriptor> call : calls) { for (ResolvedCall<?> call : calls) {
stringBuilder.append("<li>"); stringBuilder.append("<li>");
CallableDescriptor funDescriptor = call.getResultingDescriptor(); CallableDescriptor funDescriptor = call.getResultingDescriptor();
Set<ValueParameterDescriptor> parametersToHighlight = getParametersToHighlight(call); Set<ValueParameterDescriptor> parametersToHighlight = getParametersToHighlight(call);
@@ -55,7 +55,6 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.List;
import java.util.Map; import java.util.Map;
import static org.jetbrains.jet.lang.resolve.BindingContext.*; import static org.jetbrains.jet.lang.resolve.BindingContext.*;
@@ -200,14 +199,13 @@ public class ResolveToolWindow extends JPanel implements Disposable {
private static String renderDebugInfo( private static String renderDebugInfo(
PsiElement currentElement, PsiElement currentElement,
@Nullable ResolutionDebugInfo.Data debugInfo, @Nullable ResolutionDebugInfo.Data debugInfo,
@Nullable ResolvedCall<? extends CallableDescriptor> call @Nullable ResolvedCall<?> call
) { ) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
if (debugInfo != null) { if (debugInfo != null) {
List<? extends ResolutionTask<? extends CallableDescriptor, ?>> resolutionTasks = debugInfo.get(TASKS); for (ResolutionTask<?, ?> resolutionTask : debugInfo.get(TASKS)) {
for (ResolutionTask<? extends CallableDescriptor, ?> resolutionTask : resolutionTasks) { for (ResolvedCallWithTrace<?> resolvedCall : resolutionTask.getResolvedCalls()) {
for (ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall : resolutionTask.getResolvedCalls()) {
renderResolutionLogForCall(debugInfo, resolvedCall, result); renderResolutionLogForCall(debugInfo, resolvedCall, result);
} }
} }
@@ -225,11 +223,7 @@ public class ResolveToolWindow extends JPanel implements Disposable {
return result.toString(); return result.toString();
} }
private static void renderResolutionLogForCall( private static void renderResolutionLogForCall(Data debugInfo, ResolvedCallWithTrace<?> resolvedCall, StringBuilder result) {
Data debugInfo,
ResolvedCallWithTrace<? extends CallableDescriptor> resolvedCall,
StringBuilder result
) {
result.append("Trying to call ").append(resolvedCall.getCandidateDescriptor()).append("\n"); result.append("Trying to call ").append(resolvedCall.getCandidateDescriptor()).append("\n");
StringBuilder errors = debugInfo.getByKey(ERRORS, resolvedCall); StringBuilder errors = debugInfo.getByKey(ERRORS, resolvedCall);
if (errors != null) { if (errors != null) {
@@ -265,7 +259,7 @@ public class ResolveToolWindow extends JPanel implements Disposable {
} }
} }
private static String renderCall(StringBuilder builder, ResolvedCall<? extends CallableDescriptor> resolvedCall) { private static String renderCall(StringBuilder builder, ResolvedCall<?> resolvedCall) {
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor(); CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
ReceiverValue receiverArgument = resolvedCall.getReceiverArgument(); ReceiverValue receiverArgument = resolvedCall.getReceiverArgument();
ReceiverValue thisObject = resolvedCall.getThisObject(); ReceiverValue thisObject = resolvedCall.getThisObject();
@@ -67,7 +67,7 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
if (!(callee instanceof JetReferenceExpression)) return Collections.emptyList(); if (!(callee instanceof JetReferenceExpression)) return Collections.emptyList();
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) argument.getContainingFile()).getBindingContext(); BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) argument.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee); ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, (JetReferenceExpression) callee);
if (resolvedCall == null) return Collections.emptyList(); if (resolvedCall == null) return Collections.emptyList();
CallableDescriptor callableDescriptor = resolvedCall.getResultingDescriptor(); CallableDescriptor callableDescriptor = resolvedCall.getResultingDescriptor();
@@ -19,7 +19,6 @@ package org.jetbrains.jet.plugin.quickfix;
import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiErrorElement; import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
@@ -27,7 +26,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException; import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
@@ -187,8 +185,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
JetBinaryExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpression.class); JetBinaryExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpression.class);
assert expression != null : "COMPARE_TO_TYPE_MISMATCH reported on element that is not within any expression"; assert expression != null : "COMPARE_TO_TYPE_MISMATCH reported on element that is not within any expression";
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) expression.getContainingFile()).getBindingContext(); BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) expression.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
expression.getOperationReference());
if (resolvedCall == null) return null; if (resolvedCall == null) return null;
PsiElement compareTo = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor()); PsiElement compareTo = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
if (!(compareTo instanceof JetFunction)) return null; if (!(compareTo instanceof JetFunction)) return null;
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters2; import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters2;
import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.diagnostics.Errors;
@@ -72,7 +71,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
// Fixing overloaded operators: // Fixing overloaded operators:
if (expression instanceof JetOperationExpression) { if (expression instanceof JetOperationExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall =
context.get(BindingContext.RESOLVED_CALL, ((JetOperationExpression) expression).getOperationReference()); context.get(BindingContext.RESOLVED_CALL, ((JetOperationExpression) expression).getOperationReference());
if (resolvedCall != null) { if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor()); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
@@ -84,7 +83,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
if (expression.getParent() instanceof JetBinaryExpression) { if (expression.getParent() instanceof JetBinaryExpression) {
JetBinaryExpression parentBinary = (JetBinaryExpression) expression.getParent(); JetBinaryExpression parentBinary = (JetBinaryExpression) expression.getParent();
if (parentBinary.getRight() == expression) { if (parentBinary.getRight() == expression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, parentBinary.getOperationReference()); ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, parentBinary.getOperationReference());
if (resolvedCall != null) { if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor()); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
if (declaration instanceof JetFunction) { if (declaration instanceof JetFunction) {
@@ -97,7 +96,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
// Change function return type when TYPE_MISMATCH is reported on call expression: // Change function return type when TYPE_MISMATCH is reported on call expression:
if (expression instanceof JetCallExpression) { if (expression instanceof JetCallExpression) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = ResolvedCall<?> resolvedCall =
context.get(BindingContext.RESOLVED_CALL, ((JetCallExpression) expression).getCalleeExpression()); context.get(BindingContext.RESOLVED_CALL, ((JetCallExpression) expression).getCalleeExpression());
if (resolvedCall != null) { if (resolvedCall != null) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor()); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getResultingDescriptor());
@@ -99,7 +99,7 @@ public class QuickFixUtil {
@Nullable @Nullable
public static JetParameterList getParameterListOfCallee(@NotNull JetCallExpression callExpression) { public static JetParameterList getParameterListOfCallee(@NotNull JetCallExpression callExpression) {
BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) callExpression.getContainingFile()).getBindingContext(); BindingContext context = AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) callExpression.getContainingFile()).getBindingContext();
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression()); ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
if (resolvedCall == null) return null; if (resolvedCall == null) return null;
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor()); PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context, resolvedCall.getCandidateDescriptor());
if (declaration instanceof JetFunction) { if (declaration instanceof JetFunction) {
@@ -45,12 +45,11 @@ import com.intellij.refactoring.util.RefactoringMessageDialog;
import com.intellij.util.Function; import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -344,7 +343,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
JetExpression callee = callExpression.getCalleeExpression(); JetExpression callee = callExpression.getCalleeExpression();
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer); BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer);
ResolvedCall<? extends CallableDescriptor> call = context.get(BindingContext.RESOLVED_CALL, callee); ResolvedCall<?> call = context.get(BindingContext.RESOLVED_CALL, callee);
if (call == null) { if (call == null) {
return null; return null;
} }
@@ -20,7 +20,6 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.TextRange;
import com.intellij.psi.MultiRangeReference; import com.intellij.psi.MultiRangeReference;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -49,7 +48,7 @@ class JetInvokeFunctionReference extends JetSimpleReference<JetCallExpression> i
@Override @Override
@NotNull @NotNull
protected Collection<DeclarationDescriptor> getTargetDescriptors(@NotNull BindingContext context) { protected Collection<DeclarationDescriptor> getTargetDescriptors(@NotNull BindingContext context) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(RESOLVED_CALL, getExpression().getCalleeExpression()); ResolvedCall<?> resolvedCall = context.get(RESOLVED_CALL, getExpression().getCalleeExpression());
if (resolvedCall instanceof VariableAsFunctionResolvedCall) { if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return Collections.<DeclarationDescriptor>singleton(((VariableAsFunctionResolvedCall) resolvedCall).getCandidateDescriptor()); return Collections.<DeclarationDescriptor>singleton(((VariableAsFunctionResolvedCall) resolvedCall).getCandidateDescriptor());
} }
@@ -20,7 +20,6 @@ import com.google.dart.compiler.backend.js.ast.*;
import com.intellij.util.SmartList; import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor; import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
@@ -125,7 +124,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
@NotNull @NotNull
private List<JsExpression> translateArguments(@NotNull JetDelegatorToSuperCall superCall) { private List<JsExpression> translateArguments(@NotNull JetDelegatorToSuperCall superCall) {
ResolvedCall<? extends CallableDescriptor> call = context().bindingContext().get(BindingContext.RESOLVED_CALL, superCall.getCalleeExpression()); ResolvedCall<?> call = context().bindingContext().get(BindingContext.RESOLVED_CALL, superCall.getCalleeExpression());
assert call != null : "ResolvedCall for superCall must be not null"; assert call != null : "ResolvedCall for superCall must be not null";
return CallArgumentTranslator.translate(call, null, context()).getTranslateArguments(); return CallArgumentTranslator.translate(call, null, context()).getTranslateArguments();
} }
@@ -137,17 +137,15 @@ public final class BindingUtils {
} }
@NotNull @NotNull
public static ResolvedCall<?> getResolvedCall(@NotNull BindingContext context, public static ResolvedCall<?> getResolvedCall(@NotNull BindingContext context, @NotNull JetExpression expression) {
@NotNull JetExpression expression) { ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call"); assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call");
return resolvedCall; return resolvedCall;
} }
@NotNull @NotNull
public static ResolvedCall<?> getResolvedCallForProperty(@NotNull BindingContext context, public static ResolvedCall<?> getResolvedCallForProperty(@NotNull BindingContext context, @NotNull JetExpression expression) {
@NotNull JetExpression expression) { ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
ResolvedCall<? extends CallableDescriptor> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call"); assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call");
if (resolvedCall instanceof VariableAsFunctionResolvedCall) { if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
return ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall(); return ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall();