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