Skip to content

[4.2][CSRanking] Swift 4.1 compatibility hack for favouring properties on concrete types over protocols #19288

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

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Sep 13, 2018

(4.2 cherry-pick of #18952)

  • Explanation: For some protocol P and non-conforming class C where both types declare a property foo, in contexts where members from both C and P are accessible, an access to foo would be considered ambiguous.

  • Scope: Resolves a 4.2 source compatibility regression.

  • SR Issue: SR-7425

  • Risk: Low – the added logic is narrow and specifically designed not to introduce any new ambiguities.

  • Testing: Added tests for Swift 4 property overloading behaviour, Test suite, Compatibility suite

  • Reviewers: @rudkx

…concrete types over protocols

Changes in shadowing behaviour by swiftlang#15412 caused a property on a concrete type to no longer shadow a protocol property member, which created unintentional ambiguities in 4.2. This commit ensures we at least keep these cases unambiguous in Swift 5 under Swift 4 compatibility mode. This is intentionally narrow in order to best preserve source compatibility under Swift 4 mode by ensuring we don't introduce any new ambiguities.

Resolves SR-7425, SR-7940 & SR-8343.
Update the patch to account for a couple of master changes that aren't in 4.2:
- `getAsNominalTypeOrNominalTypeExtensionContext` was renamed to `getSelfNominalTypeDecl`
- Superclass constrained protocols aren't implemented
@rudkx
Copy link
Contributor

rudkx commented Sep 13, 2018

@swift-ci Please smoke test

@rudkx
Copy link
Contributor

rudkx commented Sep 13, 2018

@swift-ci Please test source compatibility

@rudkx
Copy link
Contributor

rudkx commented Sep 15, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 90410a0

@hamishknight
Copy link
Contributor Author

@rudkx Looks like the Linux test timed out, could you try again?

@rudkx
Copy link
Contributor

rudkx commented Sep 17, 2018

@swift-ci Please smoke test Linux platform

@hamishknight
Copy link
Contributor Author

@rudkx As I understand it, it's the full Linux test that needs re-running – could you please kick it off?

@rudkx
Copy link
Contributor

rudkx commented Sep 18, 2018

Ah yes, I always reach for the "saved reply" for smoke testing.

@rudkx
Copy link
Contributor

rudkx commented Sep 18, 2018

@swift-ci Please test Linux platform

@hamishknight
Copy link
Contributor Author

Any news on this (and #19562)? I don't know when the cut off point for getting stuff into 4.2.1 is, so I don't know how urgent it is.

@tkremenek
Copy link
Member

I sincerely apologize for now seeing this sooner, and I appreciate you filing the PR.

Swift 4.2.1 is a very focused release, and there are always a chance of regressions being introduced by changes like this. We should hold this fix to Swift 5.

@tkremenek tkremenek closed this Oct 8, 2018
@hamishknight hamishknight deleted the 4.2-concrete-is-better-swift4 branch October 8, 2018 19:02
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.

4 participants