-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Synthesize accessors for dynamic global variables #20570
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
Synthesize accessors for dynamic global variables #20570
Conversation
@swift-ci Please smoke test |
@swift-ci Please smoke test |
lib/Sema/TypeCheckDecl.cpp
Outdated
@@ -2470,6 +2470,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> { | |||
|
|||
void visitBoundVariable(VarDecl *VD) { | |||
TC.validateDecl(VD); | |||
TC.addImplicitDynamicAttribute(VD); |
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.
Note that typeCheckDecl() only gets called for stuff in the primary file(s). Is addImplicitDynamicAttribute() only for debugging? Even still, does it matter if its not called on things in other files that are referenced from the primary file?
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.
:/
The right way do this would be to check in the isDynamic request if the decl is from the "current module" and add it if requested?
lib/Sema/CodeSynthesis.cpp
Outdated
@@ -2042,6 +2042,12 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC, | |||
return; | |||
|
|||
if (!dc->isTypeContext()) { | |||
// dynamic globals need accessors. | |||
if (dc->isModuleScopeContext() && storage->isDynamic() && |
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.
isDynamic() && !isObjC()
seems like a common enough predicate in your changes that it might be worth extracting isObjCDynamic() and isNativeDynamic().
@swift-ci Please test |
Build failed |
Build failed |
No description provided.