Skip to content

Commit 94cdb51

Browse files
committed
[IDE] Disable constraint system diagnostics during code completion
It seems disabling diagnstics doesn't introduce any regression. rdar://problem/50679428
1 parent cc668c2 commit 94cdb51

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

include/swift/AST/DiagnosticEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ namespace swift {
634634
}
635635

636636
/// Return all \c DiagnosticConsumers.
637-
ArrayRef<DiagnosticConsumer *> getConsumers() {
637+
ArrayRef<DiagnosticConsumer *> getConsumers() const {
638638
return Consumers;
639639
}
640640

include/swift/AST/DiagnosticSuppression.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class DiagnosticSuppression {
3737
public:
3838
explicit DiagnosticSuppression(DiagnosticEngine &diags);
3939
~DiagnosticSuppression();
40+
static bool isEnabled(const DiagnosticEngine &diags);
4041
};
4142

4243
}

lib/AST/DiagnosticEngine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,10 @@ DiagnosticSuppression::~DiagnosticSuppression() {
923923
diags.addConsumer(*consumer);
924924
}
925925

926+
bool DiagnosticSuppression::isEnabled(const DiagnosticEngine &diags) {
927+
return diags.getConsumers().empty();
928+
}
929+
926930
BufferIndirectlyCausingDiagnosticRAII::BufferIndirectlyCausingDiagnosticRAII(
927931
const SourceFile &SF)
928932
: Diags(SF.getASTContext().Diags) {

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/AST/ASTVisitor.h"
2525
#include "swift/AST/ASTWalker.h"
2626
#include "swift/AST/DiagnosticsParse.h"
27+
#include "swift/AST/DiagnosticSuppression.h"
2728
#include "swift/AST/ExistentialLayout.h"
2829
#include "swift/AST/Initializer.h"
2930
#include "swift/AST/NameLookup.h"
@@ -2175,7 +2176,8 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
21752176
// Construct a constraint system from this expression.
21762177
ConstraintSystemOptions csOptions = ConstraintSystemFlags::AllowFixes;
21772178

2178-
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics))
2179+
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics) ||
2180+
DiagnosticSuppression::isEnabled(Diags))
21792181
csOptions |= ConstraintSystemFlags::SuppressDiagnostics;
21802182

21812183
if (options.contains(TypeCheckExprFlags::AllowUnresolvedTypeVariables))

0 commit comments

Comments
 (0)