@@ -842,8 +842,8 @@ void swift::expandAccessors(
842
842
// FIXME: Almost entirely duplicated code from `expandAccessors`.
843
843
// Factor this out into an `expandAttachedMacro` function, with
844
844
// arguments for the PrettyStackTrace string, 'attachedTo' decl, etc.
845
- void swift::expandAttributes (
846
- CustomAttr *attr, MacroDecl *macro, Decl *member ) {
845
+ void swift::expandAttributes (CustomAttr *attr, MacroDecl *macro, Decl *member,
846
+ SemanticDeclAttributes &result ) {
847
847
auto *dc = member->getInnermostDeclContext ();
848
848
ASTContext &ctx = dc->getASTContext ();
849
849
SourceManager &sourceMgr = ctx.SourceMgr ;
@@ -1004,6 +1004,17 @@ void swift::expandAttributes(
1004
1004
" type checking expanded declaration macro" , member);
1005
1005
1006
1006
auto topLevelDecls = macroSourceFile->getTopLevelDecls ();
1007
+ for (auto decl : topLevelDecls) {
1008
+ // FIXME: We want to type check decl attributes applied to
1009
+ // the real declaration, ideally by appending the new attributes
1010
+ // to the result and changing TypeChecker::checkDeclAttributes
1011
+ // to use the semantic attribute list.
1012
+ decl->setDeclContext (dc);
1013
+ TypeChecker::typeCheckDecl (decl);
1007
1014
1008
- // TODO: Return the attribute lists attached to top-level decls.
1015
+ // Add the new attributes to the semantic attribute list.
1016
+ for (auto *attr : decl->getAttrs ()) {
1017
+ result.add (attr);
1018
+ }
1019
+ }
1009
1020
}
0 commit comments