|
26 | 26 | #include "swift/ClangImporter/ClangModule.h"
|
27 | 27 | #include "swift/Parse/CodeCompletionCallbacks.h"
|
28 | 28 | #include "swift/Sema/IDETypeChecking.h"
|
| 29 | +#include "swift/Basic/Defer.h" // must be included after Tokens.def. |
29 | 30 | #include "swift/Subsystems.h"
|
30 | 31 | #include "llvm/ADT/SmallSet.h"
|
31 | 32 | #include "llvm/ADT/SmallString.h"
|
|
42 | 43 | #include <algorithm>
|
43 | 44 | #include <string>
|
44 | 45 |
|
| 46 | +#undef defer // for Tokens.def; use defer_impl instead. |
| 47 | + |
45 | 48 | using namespace swift;
|
46 | 49 | using namespace ide;
|
47 | 50 |
|
@@ -3246,6 +3249,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
|
3246 | 3249 | CodeCompletionExpr CCE((SourceRange()));
|
3247 | 3250 | sequence.back() = &CCE;
|
3248 | 3251 |
|
| 3252 | + defer_impl { |
| 3253 | + // Reset sequence. |
| 3254 | + SE->setElement(SE->getNumElements() - 1, nullptr); |
| 3255 | + SE->setElement(SE->getNumElements() - 2, nullptr); |
| 3256 | + eraseErrorTypes(SE); |
| 3257 | + }; |
| 3258 | + |
3249 | 3259 | Expr *expr = SE;
|
3250 | 3260 | if (!typeCheckCompletionSequence(const_cast<DeclContext *>(CurrDeclContext),
|
3251 | 3261 | expr)) {
|
@@ -3336,13 +3346,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
|
3336 | 3346 | tryPostfixOperator(LHS, cast<PostfixOperatorDecl>(op));
|
3337 | 3347 | break;
|
3338 | 3348 | case DeclKind::InfixOperator:
|
3339 |
| - if (seenInfixOperators.insert(op->getName()).second) { |
| 3349 | + if (seenInfixOperators.insert(op->getName()).second) |
3340 | 3350 | tryInfixOperatorCompletion(cast<InfixOperatorDecl>(op), SE);
|
3341 |
| - // Reset sequence. |
3342 |
| - eraseErrorTypes(SE); |
3343 |
| - SE->setElement(SE->getNumElements() - 1, nullptr); |
3344 |
| - SE->setElement(SE->getNumElements() - 2, nullptr); |
3345 |
| - } |
3346 | 3351 | break;
|
3347 | 3352 | default:
|
3348 | 3353 | llvm_unreachable("unexpected operator kind");
|
|
0 commit comments