[4.1] [Sema] Disallow conditional conformances on objective-c generics. #14665
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.
• 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. ifx
is aFoo<Bar>
whereextension Foo: SomeProtocol where T == Int
, then the cast above requires checking (and failing, in this case) thatT == 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