Skip to content

Allow "protocol P : class, AnyObject..." for Swift 4 compatibility. #11989

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

DougGregor
Copy link
Member

@DougGregor DougGregor commented Sep 18, 2017

Explanation: A simplification to the handling of the deprecated class constraint introduced as part of #11786 (for rdar://problem/34274386) started rejecting protocols such as protocol P : class, AnyObject { }, turning a warning into an error. Address this source-compatibility break by downgrading the error in that specific case to a warning.
Scope: Very narrow; downgrades a specific error to a warning.
Radar: rdar://problem/34496151
Risk: Very low; only affects one code path where we are already emitting a warning.
Testing: Compiler regression tests.
Reviewed By: @slavapestov

Because of the way we modeled the 'class' constraint in Swift <= 4, we
allowed both 'class' and 'AnyObject' to be specified on a protocol,
even in Swift 4 when they became equivalent. Recent refactoring
started rejecting such code; allow it now.

Fixes rdar://problem/34496151.

(cherry picked from commit d0aa22c)
@DougGregor
Copy link
Member Author

@swift-ci please test

@slavapestov
Copy link
Contributor

LGTM

@DougGregor
Copy link
Member Author

@swift-ci Please nominate

@DougGregor DougGregor merged commit 2c60469 into swiftlang:swift-4.0-branch Sep 18, 2017
@DougGregor DougGregor deleted the protocol-class-anyobject-source-compat-4.0 branch September 18, 2017 23:35
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