Skip to content

Tbkka radar59302422 swift 5.2 #29883

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
merged 2 commits into from
Feb 18, 2020

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Feb 17, 2020

An earlier fix for certain protocol casts inadvertently disabled
the check for a protocol being cast to its own metatype.
This rearranges the code so that identical types always succeed.
It also updates swift_dynamicCastMetatypeUnconditional to
include recent changes to swift_dynamicCastMetatype.

Note: These fixes only apply to debug/non-optimized builds.
Cast optimizations still break a lot of these cases.

Scope: This restores the ability to cast type identifiers (e.g. T.self and P.self) to their direct type (T.Type and P.Protocol, respectively). It also ensures that as! supports the same behaviors for protocol existentials as as? does.

Resolves SR-12161
Resolves rdar://59302422

Risk: Minor. This comprises two code changes: The first migrates a block of code so that the check for exact type equality always occurs first. The second duplicates a block of code added to as? processing back in October 2019 to also be used in as! handling.

Testing: The unit tests have been expanded to provide good coverage of these cases.

An earlier fix for certain protocol casts inadvertently disabled
the check for a protocol being cast to its own metatype.
This rearranges the code so that identical types always succeed.
It also updates swift_dynamicCastMetatypeUnconditional to
include recent changes to swift_dynamicCastMetatype.

Note: These fixes only apply to debug/non-optimized builds.
Cast optimizations still break a lot of these cases.
In particular, distinguish more clearly between casting for
protocol conformance versus casting for protocol type testing.
Restore the previously-correct tests back to their original status.
Also, re-enable some checks in optimized builds that are passing now.
@tbkka tbkka requested review from mikeash and rjmccall February 17, 2020 16:54
@tbkka tbkka requested a review from a team as a code owner February 17, 2020 16:54
@tbkka
Copy link
Contributor Author

tbkka commented Feb 17, 2020

@swift-ci Please test Linux

@tbkka
Copy link
Contributor Author

tbkka commented Feb 17, 2020

@swift-ci Please test macOS

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6515483

@tbkka
Copy link
Contributor Author

tbkka commented Feb 17, 2020

@swift-ci Please smoke test Linux

@tbkka
Copy link
Contributor Author

tbkka commented Feb 17, 2020

@swift-ci Please test Linux

@tbkka tbkka merged commit e2bb113 into swiftlang:swift-5.2-branch Feb 18, 2020
@tbkka tbkka deleted the tbkka-radar59302422-swift-5.2 branch October 16, 2020 00:33
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.

4 participants