Skip to content

Correct getAccessStrategy for class extension storage decls. #10050

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

Merged

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Jun 1, 2017

Class extension methods are non-polymorphic unless @objc. Fixes rdar://problem/32434652.

Class extension methods are non-polymorphic unless @objc. Fixes rdar://problem/32434652.
@jckarter
Copy link
Contributor Author

jckarter commented Jun 1, 2017

@slavapestov @jrose-apple Are there any other edge cases to account for here?

@jckarter
Copy link
Contributor Author

jckarter commented Jun 1, 2017

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

LGTM.

@jckarter jckarter merged commit db32480 into swiftlang:master Jun 2, 2017
return false;
// Extension properties are statically dispatched, unless they're @objc.
if (storage->getDeclContext()->isExtensionContext()
&& !storage->isObjC())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a coincidence rather than a design decision. I'd rather not put that into key path logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully expect us to get overridable methods in extensions some day, and that will include computed properties.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a distinction to be made between "imported from ObjC" and "declared @objc" and "@objc dynamic"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't keypath-specific, it's part of AbstractStorageDecl::getAccessStrategy. When we change the language, this seems like the right place to centralize that logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just be implicitly marking extension declarations final than put special cases for them all over the place. This might be the right place to put one, but it's not the only one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that making them final is a better fix, but might be a bit too invasive for 4.0. Do we have a bug for that?

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