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 @@ -2818,6 +2818,10 @@ class ConstraintSystem {
2818
2818
// / Associate an argument list with a call at a given locator.
2819
2819
void associateArgumentList (ConstraintLocator *locator, ArgumentList *args);
2820
2820
2821
+ // / If the given node is a function expression with a parent ApplyExpr,
2822
+ // / returns the apply, otherwise returns the node itself.
2823
+ ASTNode includingParentApply (ASTNode node);
2824
+
2821
2825
std::optional<SelectedOverload>
2822
2826
findSelectedOverloadFor (ConstraintLocator *locator) const {
2823
2827
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 @@ -6531,6 +6531,16 @@ static bool shouldHaveDirectCalleeOverload(const CallExpr *callExpr) {
6531
6531
}
6532
6532
#endif
6533
6533
6534
+ ASTNode ConstraintSystem::includingParentApply (ASTNode node) {
6535
+ if (auto *expr = getAsExpr (node)) {
6536
+ if (auto apply = getAsExpr<ApplyExpr>(getParentExpr (expr))) {
6537
+ if (apply->getFn () == expr)
6538
+ return apply;
6539
+ }
6540
+ }
6541
+ return node;
6542
+ }
6543
+
6534
6544
Type Solution::resolveInterfaceType (Type type) const {
6535
6545
auto resolvedType = type.transform ([&](Type type) -> Type {
6536
6546
if (auto *tvt = type->getAs <TypeVariableType>()) {
You can’t perform that action at this time.
0 commit comments