@@ -486,6 +486,11 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
486
486
// Build temporary expression to typecheck.
487
487
// We allocate these expressions on the stack because we know they can't
488
488
// escape and there isn't a better way to allocate scratch Expr nodes.
489
+
490
+ // Use a placeholder expr for the LHS argument to avoid sending
491
+ // a pre-type-checked AST through the constraint system.
492
+ OpaqueValueExpr argExpr (LHS->getSourceRange (), LHSTy,
493
+ /* isPlaceholder=*/ true );
489
494
UnresolvedDeclRefExpr UDRE (DeclNameRef (opName), refKind, DeclNameLoc (Loc));
490
495
auto *opExpr = TypeChecker::resolveDeclRefExpr (
491
496
&UDRE, DC, /* replaceInvalidRefsWithErrors=*/ true );
@@ -497,7 +502,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
497
502
// (declref_expr name=<opName>)
498
503
// (argument_list
499
504
// (<LHS>)))
500
- auto *postfixExpr = PostfixUnaryExpr::create (ctx, opExpr, LHS );
505
+ auto *postfixExpr = PostfixUnaryExpr::create (ctx, opExpr, &argExpr );
501
506
return getTypeOfCompletionOperatorImpl (DC, postfixExpr, referencedDecl);
502
507
}
503
508
@@ -508,7 +513,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
508
513
// (<LHS>)
509
514
// (code_completion_expr)))
510
515
CodeCompletionExpr dummyRHS (Loc);
511
- auto *binaryExpr = BinaryExpr::create (ctx, LHS , opExpr, &dummyRHS,
516
+ auto *binaryExpr = BinaryExpr::create (ctx, &argExpr , opExpr, &dummyRHS,
512
517
/* implicit*/ true );
513
518
return getTypeOfCompletionOperatorImpl (DC, binaryExpr, referencedDecl);
514
519
}
0 commit comments