diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java index 860cf9327ec..371c1150b02 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java @@ -25,16 +25,23 @@ import org.jetbrains.jet.lang.types.JetType; public class BasicResolutionContext extends ResolutionContext { @NotNull - public static BasicResolutionContext create(@NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull Call call, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo) { - return new BasicResolutionContext(trace, scope, call, expectedType, dataFlowInfo); + public static BasicResolutionContext create( + @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) { - super(trace, scope, call, expectedType, dataFlowInfo); + private BasicResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) { + super(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); } @NotNull public BasicResolutionContext replaceTrace(@NotNull BindingTrace trace) { - return create(trace, scope, call, expectedType, dataFlowInfo); + return create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java index 74b7319edd0..52fb83744b3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java @@ -30,29 +30,41 @@ public final class CallResolutionContext candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { - super(trace, task.scope, call, task.expectedType, task.dataFlowInfo); + private CallResolutionContext( + @NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask 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.tracing = tracing; this.candidateCall.setInitialDataFlowInfo(dataFlowInfo); } - private CallResolutionContext(@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull ResolvedCallImpl candidateCall) { - super(context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo); + private CallResolutionContext( + @NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, + @NotNull ResolvedCallImpl candidateCall + ) { + super(context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.namespacesAllowed); this.candidateCall = candidateCall; this.tracing = tracing; this.candidateCall.setInitialDataFlowInfo(dataFlowInfo); } - public static CallResolutionContext create(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { - return new CallResolutionContext(candidateCall, task, trace, tracing, call); + public static CallResolutionContext create( + @NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, + @NotNull TracingStrategy tracing, @NotNull Call call) { + return new CallResolutionContext(candidateCall, task, trace, tracing, call, task.namespacesAllowed); } - public static CallResolutionContext create(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) { + public static CallResolutionContext create( + @NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, + @NotNull TracingStrategy tracing) { return create(candidateCall, task, trace, tracing, task.call); } - public static CallResolutionContext create(@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull ResolvedCallImpl candidateCall) { + public static CallResolutionContext create( + @NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, + @NotNull ResolvedCallImpl candidateCall) { return new CallResolutionContext(context, tracing, candidateCall); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index c6a7214c768..6dfbcf11d11 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -122,9 +122,9 @@ public class CallResolver { @NotNull JetScope scope, @NotNull Call call, @NotNull JetType expectedType, - @NotNull DataFlowInfo dataFlowInfo) { - - return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo)); + @NotNull DataFlowInfo dataFlowInfo + ) { + return resolveFunctionCall(BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, false)); } @NotNull @@ -480,7 +480,7 @@ public class CallResolver { public List getFunctionLiteralArguments() { return Collections.emptyList(); } - }, task.expectedType, task.dataFlowInfo); + }, task.expectedType, task.dataFlowInfo, task.namespacesAllowed); OverloadResolutionResultsImpl resultsWithFunctionLiteralsStripped = performResolution(newTask, callTransformer, traceForResolutionCache); if (resultsWithFunctionLiteralsStripped.isSuccess() || resultsWithFunctionLiteralsStripped.isAmbiguity()) { task.tracing.danglingFunctionLiteralArgumentSuspected(task.trace, task.call.getFunctionLiteralArguments()); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java index 68147e374a8..1aa74ceb22f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java @@ -190,7 +190,8 @@ public class CallTransformer { Call functionCall = createFunctionCall(context, task, returnType); 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 OverloadResolutionResults results = callResolver.resolveCallWithGivenName(basicResolutionContext, task.reference, Name.identifier("invoke")); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java index 94bb79a425f..47d32289f1d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java @@ -28,16 +28,18 @@ public abstract class ResolutionContext { public final Call call; public final JetType expectedType; 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.scope = scope; this.call = call; this.expectedType = expectedType; this.dataFlowInfo = dataFlowInfo; + this.namespacesAllowed = namespacesAllowed; } public BasicResolutionContext toBasic() { - return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo); + return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java index 43a710870e4..4a1a6758057 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTask.java @@ -58,15 +58,16 @@ public class ResolutionTask extends R public final JetReferenceExpression reference; private DescriptorCheckStrategy checkingStrategy; - public ResolutionTask(@NotNull Collection> candidates, @NotNull JetReferenceExpression reference, - BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) { - super(trace, scope, call, expectedType, dataFlowInfo); + public ResolutionTask( + @NotNull Collection> candidates, @NotNull JetReferenceExpression reference, + BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo, boolean namespacesAllowed) { + super(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); this.candidates = candidates; this.reference = reference; } public ResolutionTask(@NotNull Collection> 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 @@ -91,7 +92,7 @@ public class ResolutionTask extends R } public ResolutionTask withTrace(BindingTrace newTrace) { - ResolutionTask newTask = new ResolutionTask(candidates, reference, newTrace, scope, call, expectedType, dataFlowInfo); + ResolutionTask newTask = new ResolutionTask(candidates, reference, newTrace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); newTask.setCheckingStrategy(checkingStrategy); return newTask; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java index e7a712ee9b9..eeaaf741586 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; 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.JetSimpleNameExpression; 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.receivers.ReceiverValue; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.JetTypeInfo; import org.jetbrains.jet.lang.types.TypeUtils; import java.util.List; @@ -143,7 +145,7 @@ public class ExpressionTypingContext { ////////// Call resolution utilities private BasicResolutionContext makeResolutionContext(@NotNull Call call) { - return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo); + return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo, namespacesAllowed); } @NotNull