Skip to content

Commit 242699f

Browse files
rintaroNathan Hawes
authored andcommitted
[IDE] Disable constraint system diagnostics during code completion
It seems disabling diagnstics doesn't introduce any regression. rdar://problem/50679428
1 parent 7e21c16 commit 242699f

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
@@ -657,7 +657,7 @@ namespace swift {
657657
}
658658

659659
/// Return all \c DiagnosticConsumers.
660-
ArrayRef<DiagnosticConsumer *> getConsumers() {
660+
ArrayRef<DiagnosticConsumer *> getConsumers() const {
661661
return Consumers;
662662
}
663663

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
@@ -950,6 +950,10 @@ DiagnosticSuppression::~DiagnosticSuppression() {
950950
diags.addConsumer(*consumer);
951951
}
952952

953+
bool DiagnosticSuppression::isEnabled(const DiagnosticEngine &diags) {
954+
return diags.getConsumers().empty();
955+
}
956+
953957
BufferIndirectlyCausingDiagnosticRAII::BufferIndirectlyCausingDiagnosticRAII(
954958
const SourceFile &SF)
955959
: 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"
@@ -2183,7 +2184,8 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
21832184
// Construct a constraint system from this expression.
21842185
ConstraintSystemOptions csOptions = ConstraintSystemFlags::AllowFixes;
21852186

2186-
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics))
2187+
if (options.contains(TypeCheckExprFlags::SuppressDiagnostics) ||
2188+
DiagnosticSuppression::isEnabled(Diags))
21872189
csOptions |= ConstraintSystemFlags::SuppressDiagnostics;
21882190

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

0 commit comments

Comments
 (0)