added 'namespacesAllowed' flag to ResolutionContext
This commit is contained in:
+12
-5
@@ -25,16 +25,23 @@ import org.jetbrains.jet.lang.types.JetType;
|
|||||||
|
|
||||||
public class BasicResolutionContext extends ResolutionContext {
|
public class BasicResolutionContext extends ResolutionContext {
|
||||||
@NotNull
|
@NotNull
|
||||||
public static BasicResolutionContext create(@NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull Call call, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo) {
|
public static BasicResolutionContext create(
|
||||||
return new BasicResolutionContext(trace, scope, call, expectedType, dataFlowInfo);
|
@NotNull BindingTrace trace,
|
||||||
|
@NotNull JetScope scope,
|
||||||
|
@NotNull Call call,
|
||||||
|
@NotNull JetType expectedType,
|
||||||
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
|
boolean namespacesAllowed
|
||||||
|
) {
|
||||||
|
return new BasicResolutionContext(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BasicResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) {
|
private BasicResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) {
|
||||||
super(trace, scope, call, expectedType, dataFlowInfo);
|
super(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public BasicResolutionContext replaceTrace(@NotNull BindingTrace trace) {
|
public BasicResolutionContext replaceTrace(@NotNull BindingTrace trace) {
|
||||||
return create(trace, scope, call, expectedType, dataFlowInfo);
|
return create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-8
@@ -30,29 +30,41 @@ public final class CallResolutionContext<D extends CallableDescriptor, F extends
|
|||||||
/*package*/ final TracingStrategy tracing;
|
/*package*/ final TracingStrategy tracing;
|
||||||
/*package*/ ReceiverValue receiverForVariableAsFunctionSecondCall = ReceiverValue.NO_RECEIVER;
|
/*package*/ ReceiverValue receiverForVariableAsFunctionSecondCall = ReceiverValue.NO_RECEIVER;
|
||||||
|
|
||||||
private CallResolutionContext(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) {
|
private CallResolutionContext(
|
||||||
super(trace, task.scope, call, task.expectedType, task.dataFlowInfo);
|
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
|
||||||
|
@NotNull TracingStrategy tracing, @NotNull Call call, boolean namespacesAllowed
|
||||||
|
) {
|
||||||
|
super(trace, task.scope, call, task.expectedType, task.dataFlowInfo, namespacesAllowed);
|
||||||
this.candidateCall = candidateCall;
|
this.candidateCall = candidateCall;
|
||||||
this.tracing = tracing;
|
this.tracing = tracing;
|
||||||
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
|
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CallResolutionContext(@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull ResolvedCallImpl<D> candidateCall) {
|
private CallResolutionContext(
|
||||||
super(context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo);
|
@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing,
|
||||||
|
@NotNull ResolvedCallImpl<D> candidateCall
|
||||||
|
) {
|
||||||
|
super(context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
|
||||||
this.candidateCall = candidateCall;
|
this.candidateCall = candidateCall;
|
||||||
this.tracing = tracing;
|
this.tracing = tracing;
|
||||||
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
|
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) {
|
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(
|
||||||
return new CallResolutionContext<D, F>(candidateCall, task, trace, tracing, call);
|
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
|
||||||
|
@NotNull TracingStrategy tracing, @NotNull Call call) {
|
||||||
|
return new CallResolutionContext<D, F>(candidateCall, task, trace, tracing, call, task.namespacesAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) {
|
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(
|
||||||
|
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
|
||||||
|
@NotNull TracingStrategy tracing) {
|
||||||
return create(candidateCall, task, trace, tracing, task.call);
|
return create(candidateCall, task, trace, tracing, task.call);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <D extends CallableDescriptor> CallResolutionContext<D, D> create(@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull ResolvedCallImpl<D> candidateCall) {
|
public static <D extends CallableDescriptor> CallResolutionContext<D, D> create(
|
||||||
|
@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing,
|
||||||
|
@NotNull ResolvedCallImpl<D> candidateCall) {
|
||||||
return new CallResolutionContext<D, D>(context, tracing, candidateCall);
|
return new CallResolutionContext<D, D>(context, tracing, candidateCall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,9 +122,9 @@ public class CallResolver {
|
|||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@NotNull Call call,
|
@NotNull Call call,
|
||||||
@NotNull JetType expectedType,
|
@NotNull JetType expectedType,
|
||||||
@NotNull DataFlowInfo dataFlowInfo) {
|
@NotNull DataFlowInfo dataFlowInfo
|
||||||
|
) {
|
||||||
return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo));
|
return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -480,7 +480,7 @@ public class CallResolver {
|
|||||||
public List<JetExpression> getFunctionLiteralArguments() {
|
public List<JetExpression> getFunctionLiteralArguments() {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}, task.expectedType, task.dataFlowInfo);
|
}, task.expectedType, task.dataFlowInfo, task.namespacesAllowed);
|
||||||
OverloadResolutionResultsImpl<F> resultsWithFunctionLiteralsStripped = performResolution(newTask, callTransformer, traceForResolutionCache);
|
OverloadResolutionResultsImpl<F> resultsWithFunctionLiteralsStripped = performResolution(newTask, callTransformer, traceForResolutionCache);
|
||||||
if (resultsWithFunctionLiteralsStripped.isSuccess() || resultsWithFunctionLiteralsStripped.isAmbiguity()) {
|
if (resultsWithFunctionLiteralsStripped.isSuccess() || resultsWithFunctionLiteralsStripped.isAmbiguity()) {
|
||||||
task.tracing.danglingFunctionLiteralArgumentSuspected(task.trace, task.call.getFunctionLiteralArguments());
|
task.tracing.danglingFunctionLiteralArgumentSuspected(task.trace, task.call.getFunctionLiteralArguments());
|
||||||
|
|||||||
@@ -190,7 +190,8 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
|
|||||||
Call functionCall = createFunctionCall(context, task, returnType);
|
Call functionCall = createFunctionCall(context, task, returnType);
|
||||||
|
|
||||||
final DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
|
final DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
|
||||||
BasicResolutionContext basicResolutionContext = BasicResolutionContext.create(variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo);
|
BasicResolutionContext basicResolutionContext = BasicResolutionContext.create(
|
||||||
|
variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
|
||||||
|
|
||||||
// 'invoke' call resolve
|
// 'invoke' call resolve
|
||||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke"));
|
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke"));
|
||||||
|
|||||||
@@ -28,16 +28,18 @@ public abstract class ResolutionContext {
|
|||||||
public final Call call;
|
public final Call call;
|
||||||
public final JetType expectedType;
|
public final JetType expectedType;
|
||||||
public final DataFlowInfo dataFlowInfo;
|
public final DataFlowInfo dataFlowInfo;
|
||||||
|
public final boolean namespacesAllowed;
|
||||||
|
|
||||||
protected ResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) {
|
protected ResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) {
|
||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.call = call;
|
this.call = call;
|
||||||
this.expectedType = expectedType;
|
this.expectedType = expectedType;
|
||||||
this.dataFlowInfo = dataFlowInfo;
|
this.dataFlowInfo = dataFlowInfo;
|
||||||
|
this.namespacesAllowed = namespacesAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicResolutionContext toBasic() {
|
public BasicResolutionContext toBasic() {
|
||||||
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo);
|
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -58,15 +58,16 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
|||||||
public final JetReferenceExpression reference;
|
public final JetReferenceExpression reference;
|
||||||
private DescriptorCheckStrategy checkingStrategy;
|
private DescriptorCheckStrategy checkingStrategy;
|
||||||
|
|
||||||
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference,
|
public ResolutionTask(
|
||||||
BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) {
|
@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference,
|
||||||
super(trace, scope, call, expectedType, dataFlowInfo);
|
BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) {
|
||||||
|
super(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
this.candidates = candidates;
|
this.candidates = candidates;
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicResolutionContext context) {
|
public ResolutionTask(@NotNull Collection<ResolutionCandidate<D>> candidates, @NotNull JetReferenceExpression reference, @NotNull BasicResolutionContext context) {
|
||||||
this(candidates, reference, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo);
|
this(candidates, reference, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -91,7 +92,7 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ResolutionTask<D, F> withTrace(BindingTrace newTrace) {
|
public ResolutionTask<D, F> withTrace(BindingTrace newTrace) {
|
||||||
ResolutionTask<D, F> newTask = new ResolutionTask<D, F>(candidates, reference, newTrace, scope, call, expectedType, dataFlowInfo);
|
ResolutionTask<D, F> newTask = new ResolutionTask<D, F>(candidates, reference, newTrace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
newTask.setCheckingStrategy(checkingStrategy);
|
newTask.setCheckingStrategy(checkingStrategy);
|
||||||
return newTask;
|
return newTask;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.Call;
|
import org.jetbrains.jet.lang.psi.Call;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
@@ -34,6 +35,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
import org.jetbrains.jet.lang.types.JetTypeInfo;
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -143,7 +145,7 @@ public class ExpressionTypingContext {
|
|||||||
////////// Call resolution utilities
|
////////// Call resolution utilities
|
||||||
|
|
||||||
private BasicResolutionContext makeResolutionContext(@NotNull Call call) {
|
private BasicResolutionContext makeResolutionContext(@NotNull Call call) {
|
||||||
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo);
|
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user