Skip to content

Commit fa8436b

Browse files
committed
[NFC] Allow extensions in SynthesizedFileUnits
1 parent 354f347 commit fa8436b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

include/swift/AST/SynthesizedFileUnit.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SynthesizedFileUnit final : public FileUnit {
2828
SourceFile &SF;
2929

3030
/// Synthesized top level declarations.
31-
TinyPtrVector<ValueDecl *> TopLevelDecls;
31+
TinyPtrVector<Decl *> TopLevelDecls;
3232

3333
/// A unique identifier representing this file; used to mark private decls
3434
/// within the file to keep them from conflicting with other files in the
@@ -43,7 +43,7 @@ class SynthesizedFileUnit final : public FileUnit {
4343
SourceFile &getSourceFile() const { return SF; }
4444

4545
/// Add a synthesized top-level declaration.
46-
void addTopLevelDecl(ValueDecl *D) { TopLevelDecls.push_back(D); }
46+
void addTopLevelDecl(Decl *D) { TopLevelDecls.push_back(D); }
4747

4848
virtual void lookupValue(DeclName name, NLKind lookupKind,
4949
SmallVectorImpl<ValueDecl *> &result) const override;
@@ -56,7 +56,7 @@ class SynthesizedFileUnit final : public FileUnit {
5656

5757
void getTopLevelDecls(SmallVectorImpl<Decl*> &results) const override;
5858

59-
ArrayRef<ValueDecl *> getTopLevelDecls() const {
59+
ArrayRef<Decl *> getTopLevelDecls() const {
6060
return TopLevelDecls;
6161
};
6262

lib/AST/Module.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,8 +2996,11 @@ void SynthesizedFileUnit::lookupValue(
29962996
DeclName name, NLKind lookupKind,
29972997
SmallVectorImpl<ValueDecl *> &result) const {
29982998
for (auto *decl : TopLevelDecls) {
2999-
if (decl->getName().matchesRef(name))
3000-
result.push_back(decl);
2999+
if (auto VD = dyn_cast<ValueDecl>(decl)) {
3000+
if (VD->getName().matchesRef(name)) {
3001+
result.push_back(VD);
3002+
}
3003+
}
30013004
}
30023005
}
30033006

0 commit comments

Comments
 (0)