Skip to content

[5.3][CSGen] Allow is patterns to infer type from enclosing context #32190

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 1 commit into from
Jun 5, 2020

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 4, 2020

Cherry-pick of #31810


  • Explanation:

Instead of assuming type of its sub-pattern is should be able
to infer type from context and then propagate that to the sub-pattern
via conversion. This enables support for patterns like .foo(_ as Foo)
where is would have a type different from _ which gets inferred
from associated value of foo and converted to Foo that becomes
a type of _ pattern.

  • Scope: is pattern used to match associated type of an enum element in if case and other constructs.

  • Resolves: rdar://problem/63510989

  • Risk: Low

  • Testing: Added regression tests

  • Reviewer: @DougGregor

Resolves: rdar://problem/63510989
(cherry picked from commit b14d965)

@xedin xedin requested a review from a team as a code owner June 4, 2020 21:30
@xedin
Copy link
Contributor Author

xedin commented Jun 4, 2020

@swift-ci please test

@theblixguy theblixguy added the r5.3 label Jun 4, 2020
@swift-ci
Copy link
Contributor

swift-ci commented Jun 4, 2020

Build failed
Swift Test OS X Platform
Git Sha - f997eb1f33c03fc2679998b1c5e12e0c81596aad

@swift-ci
Copy link
Contributor

swift-ci commented Jun 4, 2020

Build failed
Swift Test Linux Platform
Git Sha - f997eb1f33c03fc2679998b1c5e12e0c81596aad

@xedin xedin force-pushed the rdar-63510989-5.3 branch from f997eb1 to c50172c Compare June 5, 2020 00:20
@xedin
Copy link
Contributor Author

xedin commented Jun 5, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jun 5, 2020

Build failed
Swift Test OS X Platform
Git Sha - f997eb1f33c03fc2679998b1c5e12e0c81596aad

@swift-ci
Copy link
Contributor

swift-ci commented Jun 5, 2020

Build failed
Swift Test Linux Platform
Git Sha - f997eb1f33c03fc2679998b1c5e12e0c81596aad

Instead of assuming type of its sub-pattern `is` should be able
to infer type from context and then propagate that to the sub-pattern
via conversion. This enables support for patterns like `.foo(_ as Foo)`
where `is` would have a type different from `_` which gets inferred
from associated value of `foo` and converted to `Foo` that becomes
a type of `_` pattern.

Resolves: rdar://problem/63510989
(cherry picked from commit b14d965)
@xedin xedin force-pushed the rdar-63510989-5.3 branch from c50172c to a73611e Compare June 5, 2020 07:02
@xedin
Copy link
Contributor Author

xedin commented Jun 5, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jun 5, 2020

Build failed
Swift Test Linux Platform
Git Sha - c50172cfa74b8ff0a39640ca35ea309279fd7686

@swift-ci
Copy link
Contributor

swift-ci commented Jun 5, 2020

Build failed
Swift Test OS X Platform
Git Sha - c50172cfa74b8ff0a39640ca35ea309279fd7686

@xedin xedin merged commit c3609bc into swiftlang:release/5.3 Jun 5, 2020
@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.

5 participants