Skip to content

[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

Merged
merged 5 commits into from
Oct 16, 2019

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Oct 8, 2019

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

…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
@mikeash mikeash requested a review from DougGregor October 8, 2019 15:38
…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
@mikeash
Copy link
Contributor Author

mikeash commented Oct 10, 2019

@swift-ci plese test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thanks!

@mikeash
Copy link
Contributor Author

mikeash commented Oct 10, 2019

Thank you for pointing this stuff out. It would have been embarrassing to find out later.

@mikeash
Copy link
Contributor Author

mikeash commented Oct 11, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3ff277d

@mikeash
Copy link
Contributor Author

mikeash commented Oct 11, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3ff277d

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3ff277d

@mikeash
Copy link
Contributor Author

mikeash commented Oct 11, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6a3eecb

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6a3eecb

…e test even when --test-optimized is passed.

rdar://problem/56044443
@mikeash
Copy link
Contributor Author

mikeash commented Oct 15, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0aab6d2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0aab6d2

@mikeash mikeash merged commit 8dc43e6 into swiftlang:master Oct 16, 2019
tbkka added a commit to tbkka/swift that referenced this pull request May 8, 2020
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 added a commit that referenced this pull request Jul 2, 2020
* 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
tbkka added a commit to tbkka/swift that referenced this pull request Jul 6, 2020
* 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 added a commit that referenced this pull request Jul 7, 2020
* 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
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.

3 participants