Skip to content

SR-12486: T.self is Any.Protocol is broken #31662

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 7 commits into from
Jul 2, 2020

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented May 8, 2020

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 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 review from jckarter and mikeash May 8, 2020 20:17
@tbkka
Copy link
Contributor Author

tbkka commented May 8, 2020

@swift-ci Please test

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Thanks @tbkka !

@swift-ci
Copy link
Contributor

swift-ci commented May 8, 2020

Build failed
Swift Test Linux Platform
Git Sha - 4d3a8c2

@swift-ci
Copy link
Contributor

swift-ci commented May 8, 2020

Build failed
Swift Test OS X Platform
Git Sha - 4d3a8c2

@tbkka
Copy link
Contributor Author

tbkka commented May 11, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4d3a8c2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 4d3a8c2

@tbkka
Copy link
Contributor Author

tbkka commented May 12, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c402872

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c402872

@shahmishal
Copy link
Member

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c402872

@tbkka
Copy link
Contributor Author

tbkka commented Jun 30, 2020

@swift-ci Please test macOS

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c402872

@tbkka
Copy link
Contributor Author

tbkka commented Jul 1, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2020

Build failed
Swift Test Linux Platform
Git Sha - c402872

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2020

Build failed
Swift Test OS X Platform
Git Sha - c402872

@tbkka
Copy link
Contributor Author

tbkka commented Jul 1, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2020

Build failed
Swift Test Linux Platform
Git Sha - 821ae7d

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2020

Build failed
Swift Test OS X Platform
Git Sha - 821ae7d

@tbkka
Copy link
Contributor Author

tbkka commented Jul 1, 2020

Testing again after PR #32664

@tbkka
Copy link
Contributor Author

tbkka commented Jul 1, 2020

@swift-ci Please test

@tbkka tbkka merged commit f989aa2 into swiftlang:master Jul 2, 2020
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
@tbkka tbkka deleted the tbkka-SR12486-Any.Protocol-cast branch October 16, 2020 00:32
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.

5 participants