@@ -496,6 +496,12 @@ bool TypeChecker::typeCheckFunctionBuilderFuncBody(FuncDecl *FD,
496
496
options |= TypeCheckExprFlags::ConvertTypeIsOpaqueReturnType;
497
497
}
498
498
499
+ // If we are performing code-completion inside the functions body, supress
500
+ // diagnostics to workaround typechecking performance problems.
501
+ if (Context.SourceMgr .rangeContainsCodeCompletionLoc (
502
+ FD->getBody ()->getSourceRange ()))
503
+ options |= TypeCheckExprFlags::SuppressDiagnostics;
504
+
499
505
// Type-check the single result expression.
500
506
Type returnExprType = typeCheckExpression (returnExpr, FD,
501
507
TypeLoc::withoutLoc (returnType),
@@ -574,6 +580,12 @@ ConstraintSystem::TypeMatchResult ConstraintSystem::applyFunctionBuilder(
574
580
assert (!builderType->hasTypeParameter ());
575
581
}
576
582
583
+ // If we are performing code-completion inside the closure body, supress
584
+ // diagnostics to workaround typechecking performance problems.
585
+ if (getASTContext ().SourceMgr .rangeContainsCodeCompletionLoc (
586
+ closure->getSourceRange ()))
587
+ Options |= ConstraintSystemFlags::SuppressDiagnostics;
588
+
577
589
BuilderClosureVisitor visitor (getASTContext (), this ,
578
590
/* wantExpr=*/ true , builderType);
579
591
Expr *singleExpr = visitor.visit (closure->getBody ());
0 commit comments