Skip to content

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

Conversation

aschwaighofer
Copy link
Contributor

No description provided.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please smoke test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please smoke test

@@ -2470,6 +2470,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {

void visitBoundVariable(VarDecl *VD) {
TC.validateDecl(VD);
TC.addImplicitDynamicAttribute(VD);
Copy link
Contributor

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?

Copy link
Contributor Author

@aschwaighofer aschwaighofer Nov 14, 2018

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?

@@ -2042,6 +2042,12 @@ void swift::maybeAddAccessorsToStorage(TypeChecker &TC,
return;

if (!dc->isTypeContext()) {
// dynamic globals need accessors.
if (dc->isModuleScopeContext() && storage->isDynamic() &&
Copy link
Contributor

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().

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 081bb95

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 081bb95

@aschwaighofer aschwaighofer merged commit 619673e into swiftlang:master Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants