[5.3] [SR-12486] T.self is Any.Protocol
is broken
#32725
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.
Merge PR #31662 into release/5.3 branch
Description from original PR #31662
This turned out to be fallout from #27572 which was in turn motivated by our confusing metatype syntax when generic variables are bound to protocols.
In particular, the earlier PR was an attempt to make the expression
x is T.Type
(whereT
is a generic type variable bound to a protocolP
) behave the same asx is P.Type
(whereP
is a protocol). Unfortunately, the genericT.Type
actually binds toP.Protocol
in this case (notP.Type
), so the original motivation was flawed, and as it happens,x is T.Type
already behaved the same asx is P.Protocol
in this situation.This PR reverts that earlier change and beefs up some of the tests around these behaviors.
Resolves SR-12486
Resolves rdar://62201613
Reverts PR#27572
CCC Information
• Explanation: Reverts PR#27572 which broke several different runtime casts
• Scope of Issue: Restores the correct behavior from Swift 5.0
• Origination: PR#27572
• Risk: Some projects may have introduced dependencies on the Swift 5.1 or 5.2 behaviors (which were different from each other and different from the correct Swift 5.0 behavior)
• Reviewed By: Joe Groff, Mike Ash
• Automated Testing: Unit tests were augmented to clarify the correct behavior
• Impact: Runtime only