|
15 | 15 | #include "swift/AST/ASTWalker.h"
|
16 | 16 | #include "swift/AST/Decl.h"
|
17 | 17 | #include "swift/AST/Expr.h"
|
| 18 | +#include "swift/AST/NameLookup.h" |
18 | 19 | #include "swift/AST/Pattern.h"
|
19 | 20 | #include "swift/AST/ParameterList.h"
|
20 | 21 | #include "swift/AST/Module.h"
|
@@ -346,6 +347,21 @@ class ModelASTWalker : public ASTWalker {
|
346 | 347 | /// is considered as one, e.g. object literal expression.
|
347 | 348 | uint8_t AvoidPassingSyntaxToken = 0;
|
348 | 349 |
|
| 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 | + |
349 | 365 | public:
|
350 | 366 | SyntaxModelWalker &Walker;
|
351 | 367 | ArrayRef<SyntaxNode> TokenNodes;
|
@@ -890,7 +906,8 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) {
|
890 | 906 | } else if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
|
891 | 907 | // Normally bindExtension() would take care of computing the extended
|
892 | 908 | // nominal. It must be done before asking for generic parameters.
|
893 |
| - ED->computeExtendedNominal(); |
| 909 | + if (!inInactiveClause || ASTScope::areInactiveIfConfigClausesSupported()) |
| 910 | + ED->computeExtendedNominal(); |
894 | 911 | SyntaxStructureNode SN;
|
895 | 912 | setDecl(SN, D);
|
896 | 913 | SN.Kind = SyntaxStructureKind::Extension;
|
@@ -967,6 +984,7 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) {
|
967 | 984 | if (Clause.Cond && !annotateIfConfigConditionIdentifiers(Clause.Cond))
|
968 | 985 | return false;
|
969 | 986 |
|
| 987 | + InactiveClauseRAII inactiveClauseRAII(inInactiveClause, !Clause.isActive); |
970 | 988 | for (auto &Element : Clause.Elements) {
|
971 | 989 | if (auto *E = Element.dyn_cast<Expr*>()) {
|
972 | 990 | E->walk(*this);
|
|
0 commit comments