@@ -1191,24 +1191,20 @@ sawSolution(const constraints::Solution &S) {
1191
1191
// / (overloaded_decl_ref_expr function_ref=compound decls=[
1192
1192
// / Swift.(file).~=,
1193
1193
// / 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))))
1197
1199
// / \endcode
1198
1200
// / If the code completion expression occurs in such an AST, return the
1199
1201
// / declaration of the \c $match variable, otherwise return \c nullptr.
1200
1202
VarDecl *getMatchVarIfInPatternMatch (CodeCompletionExpr *CompletionExpr,
1201
1203
ConstraintSystem &CS) {
1202
1204
auto &Context = CS.getASTContext ();
1203
1205
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) {
1212
1208
return nullptr ;
1213
1209
}
1214
1210
@@ -1233,7 +1229,7 @@ VarDecl *getMatchVarIfInPatternMatch(CodeCompletionExpr *CompletionExpr,
1233
1229
return nullptr ;
1234
1230
}
1235
1231
1236
- auto MatchArg = dyn_cast_or_null<DeclRefExpr>(ArgTuple-> getElement ( 1 ));
1232
+ auto MatchArg = dyn_cast_or_null<DeclRefExpr>(Binary-> getRHS ( ));
1237
1233
if (!MatchArg || !MatchArg->isImplicit ()) {
1238
1234
return nullptr ;
1239
1235
}
0 commit comments