Skip to content

Fix printing of class-constrained protocols [4.0] #11786

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

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Sep 6, 2017

  • 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

Instead of treating this as its own thing, just parse it as if
the user wrote 'AnyObject'.
@slavapestov
Copy link
Contributor Author

@DougGregor Are you OK with taking this for 4.0? The main change is that 'protocol P : class' now parses and prints as 'protocol P : AnyObject'. Since TSPL now only talks about the latter, I think it makes sense to clean up the parser this way. This fix is not quite as narrow as I would like (I originally did it on master and then decided to cherry-pick) but I think we did enough cleanup while implementing subclass existentials that I feel confident in always modeling this as inheritance from AnyObject.

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov changed the title Fix printing of class-constrained protocols Fix printing of class-constrained protocols [4.0] Sep 6, 2017
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Much simpler

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