Skip to content

[4.2][NameLookup] Swift 4 compatibility hack for cross-module var overloads in generic type extensions #19223

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 10, 2018

(4.2 cherry-pick of #18488 + expanded test-case for dynamic overload ranking from #18952)

  • Explanation: Across modules, a property declared in an extension of a generic type would shadow another property declared elsewhere, causing the one in the other module to be inaccessible.

  • Scope: Resolves a 4.2 source compatibility regression.

  • SR Issue: SR-7341.

  • Risk: Moderately low – the added logic is fairly narrow and matches existing compatibility logic in swift::conflicting.

  • Testing: Added tests for Swift 4 and 5 cross-module property overloading behaviour, Test suite, Compatibility suite.

  • Reviewers: @slavapestov, @DougGregor.

…s in generic type extensions

In Swift 4, we only gave custom overload types to properties defined in extensions of generic types, using the null type for any other var decl. This meant that a property defined in such an extension would never shadow a property not defined in such an extension. As a result, this permitted cross-module overloads of properties of different types on generic types in certain cases.

This patch adds an exception to the shadowing rules for properties defined in generic type extensions under Swift 4 mode. Permitting cross-module property overloads in the general case would also be source breaking (causing ambiguity errors), so this can be handled in a follow-up Swift 5 mode PR if desired.

Resolves SR-7341.
@hamishknight
Copy link
Contributor Author

@slavapestov @DougGregor Could you please run CI tests? (assuming this is still something that's viable for 4.2.1)

@slavapestov
Copy link
Contributor

@swift-ci Please test

@hamishknight
Copy link
Contributor Author

Any news on this? 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.

@hamishknight
Copy link
Contributor Author

Ah, according to @jrose-apple, 4.2.1 is trying to be kept minimal.

Presumably that rules this out (and the others: #19288 & #19562)? I'll go ahead and close if so.

@tkremenek
Copy link
Member

Sorry I completely missed this. The release manager (me) is the one that needs to approve merging these. From the 4.2 release process:

All change going into the swift-4.2-branch (outside changes being merged in automatically from master) must go through pull requests that are accepted by the corresponding release manager.

The problem is that I didn't see these as my review wasn't requested nor was I CC'ed. It is true that the kind of change to take for 4.2.1 is very small; I'll take a look at these to see if they qualify, but I suspect they won't. In the future, we'll look at using the CODEOWNERS feature that GitHub provides to see if we can get the release manager notified of these PRs (and have their review required) so that the tooling is supporting the process.

@hamishknight
Copy link
Contributor Author

@tkremenek Apologies for not cc'ing you. I saw other 4.2 PRs using @swift-ci please nominate, so I assumed that was the official way to notify the suitable release manager after the original reviewer had taken a glance.

@tkremenek
Copy link
Member

No problem. I need to improve the processes in the tools to make sure the release manager sees these PRs in a more timely manner.

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

After consideration, I think we will not take this for 4.2.1. 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-swift4-cross-module-var-overload branch October 8, 2018 19:01
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