-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl #27572
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
[Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl #27572
Conversation
…eImpl. This fixes cases like `type is T.Type` when T is generic specialized to a protocol type. Note: the compiler can still optimize these checks away and will optimize this check down to `false` in some cases. We'll want to fix that as well. rdar://problem/56044443
…col conformance. This is cleaner and it fixes a bunch of cases the old code didn't handle: @objc protocols, class bounds, and superclass constraints. rdar://problem/56044443
@swift-ci plese test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thanks!
Thank you for pointing this stuff out. It would have been embarrassing to find out later. |
@swift-ci please test |
Build failed |
rdar://problem/56044443
@swift-ci please test |
Build failed |
Build failed |
rdar://problem/56044443
@swift-ci please test |
Build failed |
Build failed |
…e test even when --test-optimized is passed. rdar://problem/56044443
@swift-ci please test |
Build failed |
Build failed |
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
* SR-12486: `T.self is Any.Protocol` is broken 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
* 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
* SR-12486: `T.self is Any.Protocol` is broken 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
This fixes cases like
type is T.Type
when T is generic specialized to a protocol type.Note: the compiler can still optimize these checks away and will optimize this check down to
false
in some cases. We'll want to fix that as well.rdar://problem/56044443