Skip to content

[5.0] Don't fix access of an 'open' decl in a 'public' extension #22216

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

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jan 29, 2019

  • Explanation: This is reasonable to diagnose with a warning, but dropping the 'open' down to 'public' isn't the right fix, because it might have been an override or satisfying a protocol requirement. In that case, the declaration would have to get moved to another extension instead, or the extension has to not set a default access level.

    This turned out to be a source compat issue because the same logic that emits the fix-it also updates the access of the member, which then resulted in "must be as accessible as the declaration it overrides" in the same build. It's not immediately clear what caused this to work in 4.2 but result in an error in 5.0; probably something's just being validated in a different order than it was before. The change makes sense either way.

    Stepping back, it's weird that a warning would change how the compiler saw the code, and while we could check for 'override' explicitly, we can't know if the member might be satisfying a protocol requirement. Better to just not guess at the right answer here.

  • Scope: Affects members of extensions with a greater level of access than the extension's default.

  • Issue: rdar://problem/47557376&28493971

  • Risk: Low. We're choosing not to emit a fix-it (basically no risk), making sure we emit another diagnostic (for something that would never work), and not changing the AST from what the user wrote (a behavior change, but one that matches different source the user could have written).

  • Testing: Updated/added compiler regression tests, passed source compatibility suite.

  • Reviewed by: @brentdax, @dingobye

Don't fix access of an 'open' override in a 'public' extension

rdar://problem/47557376&28493971
(cherry picked from commit de93ba0)
@jrose-apple jrose-apple requested a review from a team as a code owner January 29, 2019 19:03
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@AnnaZaks AnnaZaks merged commit d81c3d2 into swiftlang:swift-5.0-branch Jan 29, 2019
@jrose-apple jrose-apple deleted the 5.0-open-your-heart branch January 29, 2019 22:18
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