@@ -355,31 +355,51 @@ static Expr *makeBinOp(ASTContext &Ctx, Expr *Op, Expr *LHS, Expr *RHS,
355
355
356
356
if (auto *ifExpr = dyn_cast<IfExpr>(Op)) {
357
357
// Resolve the ternary expression.
358
- assert (!ifExpr->isFolded () && " already folded if expr in sequence?!" );
358
+ if (!Ctx.CompletionCallback ) {
359
+ // In code completion we might call preCheckExpression twice - once for
360
+ // the first pass and once for the second pass. This is fine since
361
+ // preCheckExpression idempotent.
362
+ assert (!ifExpr->isFolded () && " already folded if expr in sequence?!" );
363
+ }
359
364
ifExpr->setCondExpr (LHS);
360
365
ifExpr->setElseExpr (RHS);
361
366
return ifExpr;
362
367
}
363
368
364
369
if (auto *assign = dyn_cast<AssignExpr>(Op)) {
365
370
// Resolve the assignment expression.
366
- assert (!assign->isFolded () && " already folded assign expr in sequence?!" );
371
+ if (!Ctx.CompletionCallback ) {
372
+ // In code completion we might call preCheckExpression twice - once for
373
+ // the first pass and once for the second pass. This is fine since
374
+ // preCheckExpression idempotent.
375
+ assert (!assign->isFolded () && " already folded assign expr in sequence?!" );
376
+ }
367
377
assign->setDest (LHS);
368
378
assign->setSrc (RHS);
369
379
return assign;
370
380
}
371
381
372
382
if (auto *as = dyn_cast<ExplicitCastExpr>(Op)) {
373
383
// Resolve the 'as' or 'is' expression.
374
- assert (!as->isFolded () && " already folded 'as' expr in sequence?!" );
384
+ if (!Ctx.CompletionCallback ) {
385
+ // In code completion we might call preCheckExpression twice - once for
386
+ // the first pass and once for the second pass. This is fine since
387
+ // preCheckExpression idempotent.
388
+ assert (!as->isFolded () && " already folded 'as' expr in sequence?!" );
389
+ }
375
390
assert (RHS == as && " 'as' with non-type RHS?!" );
376
391
as->setSubExpr (LHS);
377
392
return as;
378
393
}
379
394
380
395
if (auto *arrow = dyn_cast<ArrowExpr>(Op)) {
381
396
// Resolve the '->' expression.
382
- assert (!arrow->isFolded () && " already folded '->' expr in sequence?!" );
397
+ if (!Ctx.CompletionCallback ) {
398
+ // In code completion we might call preCheckExpression twice - once for
399
+ // the first pass and once for the second pass. This is fine since
400
+ // preCheckExpression idempotent.
401
+ assert (!arrow->isFolded () && " already folded '->' expr in sequence?!" );
402
+ }
383
403
arrow->setArgsExpr (LHS);
384
404
arrow->setResultExpr (RHS);
385
405
return arrow;
0 commit comments