File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -2826,6 +2826,10 @@ class ConstraintSystem {
2826
2826
// / Associate an argument list with a call at a given locator.
2827
2827
void associateArgumentList (ConstraintLocator *locator, ArgumentList *args);
2828
2828
2829
+ // / If the given node is a function expression with a parent ApplyExpr,
2830
+ // / returns the apply, otherwise returns the node itself.
2831
+ ASTNode includingParentApply (ASTNode node);
2832
+
2829
2833
std::optional<SelectedOverload>
2830
2834
findSelectedOverloadFor (ConstraintLocator *locator) const {
2831
2835
auto result = ResolvedOverloads.find (locator);
Original file line number Diff line number Diff line change @@ -1036,18 +1036,9 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
1036
1036
if (cs.isForCodeCompletion ()) {
1037
1037
// Don't rank based on overload choices of function calls that contain the
1038
1038
// code completion token.
1039
- ASTNode anchor = simplifyLocatorToAnchor (overload.locator );
1040
- if (auto expr = getAsExpr (anchor)) {
1041
- // If the anchor is a called function, also don't rank overload choices
1042
- // if any of the arguments contain the code completion token.
1043
- if (auto apply = dyn_cast_or_null<ApplyExpr>(cs.getParentExpr (expr))) {
1044
- if (apply->getFn () == expr) {
1045
- anchor = apply;
1046
- }
1047
- }
1048
- }
1049
- if (anchor && cs.containsIDEInspectionTarget (anchor)) {
1050
- continue ;
1039
+ if (auto anchor = simplifyLocatorToAnchor (overload.locator )) {
1040
+ if (cs.containsIDEInspectionTarget (cs.includingParentApply (anchor)))
1041
+ continue ;
1051
1042
}
1052
1043
}
1053
1044
Original file line number Diff line number Diff line change @@ -6658,6 +6658,16 @@ static bool shouldHaveDirectCalleeOverload(const CallExpr *callExpr) {
6658
6658
}
6659
6659
#endif
6660
6660
6661
+ ASTNode ConstraintSystem::includingParentApply (ASTNode node) {
6662
+ if (auto *expr = getAsExpr (node)) {
6663
+ if (auto apply = getAsExpr<ApplyExpr>(getParentExpr (expr))) {
6664
+ if (apply->getFn () == expr)
6665
+ return apply;
6666
+ }
6667
+ }
6668
+ return node;
6669
+ }
6670
+
6661
6671
Type Solution::resolveInterfaceType (Type type) const {
6662
6672
auto resolvedType = type.transform ([&](Type type) -> Type {
6663
6673
if (auto *tvt = type->getAs <TypeVariableType>()) {
You can’t perform that action at this time.
0 commit comments