Skip to content

Conversation

@tbkka
Copy link
Contributor

@tbkka tbkka commented Jul 6, 2020

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 (where T is a generic type variable bound to a protocol P) behave the same as x is P.Type (where P is a protocol). Unfortunately, the generic T.Type actually binds to P.Protocol in this case (not P.Type), so the original motivation was flawed, and as it happens, x is T.Type already behaved the same as x 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

* SR-12486: `T.self is Any.Protocol` is broken

This turned out to be fallout from swiftlang#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` (where `T` is a generic type variable bound to a protocol `P`)
behave the same as
`x is P.Type` (where `P` is a protocol).
Unfortunately, the generic `T.Type` actually binds to `P.Protocol` in this case (not `P.Type`), so the original motivation was flawed, and as it happens, `x is T.Type` already behaved the same as `x 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
@tbkka tbkka requested a review from a team as a code owner July 6, 2020 19:22
@tbkka
Copy link
Contributor Author

tbkka commented Jul 6, 2020

@swift-ci Please test

@tbkka
Copy link
Contributor Author

tbkka commented Jul 6, 2020

@swift-ci Please nominate

@tbkka tbkka merged commit 879e835 into swiftlang:release/5.3 Jul 7, 2020
@tbkka tbkka deleted the tbkka-SR12486-Any.Protocol-cast-5.3 branch October 16, 2020 00:33
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks swift 5.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants