Skip to content

Sema: Fix setter visibility computation when checking key path literals. #15808

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
merged 1 commit into from
Apr 9, 2018

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Apr 6, 2018

AbstractStorageDecl::isSettable by itself doesn't account for access control, so we need to check isSetterAccessibleFrom as well. Furthermore, key paths should not get the special context-sensitive privileges direct accesses do, such as initializers being able to assign into let properties. Fix the type checking logic here to only create a statically writable KeyPath value when the referenced declaration has a setter visible independent of current context. Fixes SR-6667 | rdar://problem/36257266.

@jckarter
Copy link
Contributor Author

jckarter commented Apr 6, 2018

@jrose-apple How's this look?

@jckarter
Copy link
Contributor Author

jckarter commented Apr 6, 2018

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Apr 6, 2018

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor

I would just write this as storage->isSettable(nullptr) && storage->isSetterAccessibleFrom(DC), but yeah, this looks good. It also suggests that isSettable should be renamed to something like isSettableIgnoringAccess, or that it should also call isSetterAccessibleFrom itself.

`AbstractStorageDecl::isSettable` by itself doesn't account for access control, so we need to check `isSetterAccessibleFrom` as well. Furthermore, key paths should not get the special context-sensitive privileges direct accesses do, such as initializers being able to assign into `let` properties. Fix the type checking logic here to only create a statically writable KeyPath value when the referenced declaration has a setter visible independent of current context. Fixes SR-6667 | rdar://problem/36257266.
@jckarter jckarter force-pushed the keypath-setter-visibility branch from 160c001 to 6d053f5 Compare April 9, 2018 18:06
@jckarter
Copy link
Contributor Author

jckarter commented Apr 9, 2018

@swift-ci Please smoke test

@jckarter
Copy link
Contributor Author

jckarter commented Apr 9, 2018

@swift-ci Please smoke test macOS

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.

2 participants