Skip to content

Commit cd95ddb

Browse files
author
David Ungar
committed
Don't do lookups into inactive clauses
1 parent 0838a66 commit cd95ddb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "swift/AST/ASTWalker.h"
1616
#include "swift/AST/Decl.h"
1717
#include "swift/AST/Expr.h"
18+
#include "swift/AST/NameLookup.h"
1819
#include "swift/AST/Pattern.h"
1920
#include "swift/AST/ParameterList.h"
2021
#include "swift/AST/Module.h"
@@ -346,6 +347,21 @@ class ModelASTWalker : public ASTWalker {
346347
/// is considered as one, e.g. object literal expression.
347348
uint8_t AvoidPassingSyntaxToken = 0;
348349

350+
class InactiveClauseRAII {
351+
const bool wasInInactiveClause;
352+
bool &isInInactiveClause;
353+
354+
public:
355+
InactiveClauseRAII(bool &isInInactiveClauseArg, bool enteringInactiveClause)
356+
: wasInInactiveClause(isInInactiveClauseArg),
357+
isInInactiveClause(isInInactiveClauseArg) {
358+
isInInactiveClause |= enteringInactiveClause;
359+
}
360+
~InactiveClauseRAII() { isInInactiveClause = wasInInactiveClause; }
361+
};
362+
friend class InactiveClauseRAII;
363+
bool inInactiveClause = false;
364+
349365
public:
350366
SyntaxModelWalker &Walker;
351367
ArrayRef<SyntaxNode> TokenNodes;
@@ -890,7 +906,8 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) {
890906
} else if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
891907
// Normally bindExtension() would take care of computing the extended
892908
// nominal. It must be done before asking for generic parameters.
893-
ED->computeExtendedNominal();
909+
if (!inInactiveClause || ASTScope::areInactiveIfConfigClausesSupported())
910+
ED->computeExtendedNominal();
894911
SyntaxStructureNode SN;
895912
setDecl(SN, D);
896913
SN.Kind = SyntaxStructureKind::Extension;
@@ -967,6 +984,7 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) {
967984
if (Clause.Cond && !annotateIfConfigConditionIdentifiers(Clause.Cond))
968985
return false;
969986

987+
InactiveClauseRAII inactiveClauseRAII(inInactiveClause, !Clause.isActive);
970988
for (auto &Element : Clause.Elements) {
971989
if (auto *E = Element.dyn_cast<Expr*>()) {
972990
E->walk(*this);

0 commit comments

Comments
 (0)