@@ -1191,24 +1191,20 @@ sawSolution(const constraints::Solution &S) {
11911191// / (overloaded_decl_ref_expr function_ref=compound decls=[
11921192// / Swift.(file).~=,
11931193// / Swift.(file).Optional extension.~=])
1194- // / (tuple_expr implicit type='($T1, (OtherEnum))'
1195- // / (code_completion_expr implicit type='$T1')
1196- // / (declref_expr implicit decl=swift_ide_test.(file).foo(x:).$match)))
1194+ // / (argument_list implicit
1195+ // / (argument
1196+ // / (code_completion_expr implicit type='$T1'))
1197+ // / (argument
1198+ // / (declref_expr implicit decl=swift_ide_test.(file).foo(x:).$match))))
11971199// / \endcode
11981200// / If the code completion expression occurs in such an AST, return the
11991201// / declaration of the \c $match variable, otherwise return \c nullptr.
12001202VarDecl *getMatchVarIfInPatternMatch (CodeCompletionExpr *CompletionExpr,
12011203 ConstraintSystem &CS) {
12021204 auto &Context = CS.getASTContext ();
12031205
1204- TupleExpr *ArgTuple =
1205- dyn_cast_or_null<TupleExpr>(CS.getParentExpr (CompletionExpr));
1206- if (!ArgTuple || !ArgTuple->isImplicit () || ArgTuple->getNumElements () != 2 ) {
1207- return nullptr ;
1208- }
1209-
1210- auto Binary = dyn_cast_or_null<BinaryExpr>(CS.getParentExpr (ArgTuple));
1211- if (!Binary || !Binary->isImplicit ()) {
1206+ auto *Binary = dyn_cast_or_null<BinaryExpr>(CS.getParentExpr (CompletionExpr));
1207+ if (!Binary || !Binary->isImplicit () || Binary->getLHS () != CompletionExpr) {
12121208 return nullptr ;
12131209 }
12141210
@@ -1233,7 +1229,7 @@ VarDecl *getMatchVarIfInPatternMatch(CodeCompletionExpr *CompletionExpr,
12331229 return nullptr ;
12341230 }
12351231
1236- auto MatchArg = dyn_cast_or_null<DeclRefExpr>(ArgTuple-> getElement ( 1 ));
1232+ auto MatchArg = dyn_cast_or_null<DeclRefExpr>(Binary-> getRHS ( ));
12371233 if (!MatchArg || !MatchArg->isImplicit ()) {
12381234 return nullptr ;
12391235 }
0 commit comments