-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] Create type refinement context for MacroExpansionDecl #65959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci Please smoke test |
lib/AST/TypeRefinementContext.cpp
Outdated
@@ -53,6 +53,13 @@ TypeRefinementContext::createRoot(SourceFile *SF, | |||
if (auto parentExpansion = SF->getMacroExpansion()) { | |||
if (auto parentTRC = | |||
SF->getEnclosingSourceFile()->getTypeRefinementContext()) { | |||
// FIXME: Skip `MacroExpansionDecl` context? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need this.
@@ -1482,7 +1482,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*, | |||
|
|||
bool shouldSkip(Decl *D) { | |||
if (!Walker.shouldWalkMacroArgumentsAndExpansion().second && | |||
D->isInMacroExpansionInContext()) | |||
D->isInMacroExpansionInContext() && !Walker.Parent.isNull()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeRefinementContextBuilder
doesn't walk into expansions, but It does decl->walk(builder)
on the top level decls of the synthesized buffer. In such cases, I think the caller explicitly want to walk to it regardless of the macro walk mode.
public struct FuncWithClosureMacro: DeclarationMacro { | ||
public static func expansion( | ||
of node: some FreestandingMacroExpansionSyntax, | ||
in context: some MacroExpansionContext | ||
) throws -> [DeclSyntax] { | ||
|
||
return ["func LocalFunc() {}", "var LocalVar: Int { 1 }"] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated. Will remove this
@available(macOS 99, *) | ||
#funcFromClosureMacro(APIFrom99()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test case without this attribute. to check if it's diagnosed properly
2d81379
to
d49acf9
Compare
d49acf9
to
7c2a73e
Compare
@swift-ci Please smoke test |
rdar://107386648