Skip to content

[4.1] [Sema] Disallow conditional conformances on objective-c generics. #14665

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

huonw
Copy link
Contributor

@huonw huonw commented Feb 15, 2018

• Explanation: Dynamic casts to existentials (i.e. given x: Any, x as SomeProtocol) requires looking up type information for conditional conformances to validate the requirements(i.e. if x is a Foo<Bar> where extension Foo: SomeProtocol where T == Int, then the cast above requires checking (and failing, in this case) that T == Bar == Int), and these look-ups can only happen dynamically. Metadata about the types used in objective-C generics doesn't exist at runtime and so the look-ups are impossible. We want to keep the static and dynamic type systems the same, so we have to outlaw such conditional conformances.
• Scope of Issue: Only code trying to conditionally conform a protocol to an objective-c generic type is affected, and 4.1 is the first release including conditional conformances.
• Origination: Only recently realised that this is a consequence of conditional conformances.
• Risk: Low: small change to unreleased feature.
• Reviewed By: @DougGregor
• Testing: Compiler regression tests
• Radar / SR: rdar://problem/37524969

#14628

There's no way to look up information about objective-c generic
parameters, meaning the runtime cannot check same-type constraints or
conformance requirements, so dynamic casts cannot work. We want to keep
the static and dynamic systems the same, so we have to disable this
functionality from the start (i.e. no conditional conformances on
objective-c types :( ).

Fixes rdar://problem/37524969.
@huonw
Copy link
Contributor Author

huonw commented Feb 15, 2018

@swift-ci please test

@huonw
Copy link
Contributor Author

huonw commented Feb 16, 2018

@swift-ci please nominate

@AnnaZaks AnnaZaks merged commit f2049df into swiftlang:swift-4.1-branch Feb 16, 2018
@huonw huonw deleted the no-conditional-objc-generics-4.1 branch February 16, 2018 01:17
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