Fix printing of class-constrained protocols [4.0] #11786
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: In Swift 4.0, we implemented SE-0156, which stipulates that 'protocol P : AnyObject' should be equivalent to 'protocol P : class'. Because of unfortunate representational issues, the generated interface for such a protocol produced ridiculous output like 'protocol P : class, AnyObject where Self : AnyObject'. This PR fixes that and now it just says 'protocol P : AnyObject'.
Scope of the issue: This is just a cosmetic issue, but it was reported by a user on Twitter, who was confused by the redundant constraints. It's also a regression in the sense that we're not asking users to write 'AnyObject' instead of 'class' everywhere, and the new form had this problem.
Tested: New test added to ensure the generated interface looks reasonable.
Risk: Low, I think we tested subclass existentials well enough that folding ': class' into ': AnyObject' in the parser should work as before.
Radar: rdar://problem/34274386
Reviewed by: @DougGregor