Skip to content

[Sema] Have isValidTypeExprParent consider its child #39073

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

Conversation

hamishknight
Copy link
Contributor

With the introduction of the ArgumentList type in #38836, argument expressions will be direct decedents of call expressions, without an intermediate TupleExpr. As such, we need to tweak isValidTypeExprParent to consider the child expression such that T(x) is permissible, but x(T) is not.

Change isValidTypeExprParent to take a child expr parameter, and update its use in MiscDiagnostics and PreCheckExpr. For PreCheckExpr, switch from a stack to walking the parent directly, as a stack-based approach would be a bit more fiddly in this case, and walking the parents shouldn't be expensive.

This should be NFC, I'm splitting it off from the ArgumentList refactoring to make the rebasing there a little more straightforward.

With the introduction of the ArgumentList type,
argument expressions will be direct decedents of
call expressions, without an intermediate TupleExpr.
As such, we need to tweak isValidTypeExprParent to
consider the child expression such that `T(x)` is
permissible, but `x(T)` is not.

Change isValidTypeExprParent to take a child expr
parameter, and update its use in MiscDiagnostics
and PreCheckExpr. For PreCheckExpr, switch from a
stack to walking the parent directly, as a
stack-based approach would be a bit more fiddly in
this case, and walking the parents shouldn't be
expensive.

This should be NFC, I'm splitting it off from the
ArgumentList refactoring to make the rebasing there
a little more straightforward.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight requested review from xedin and Jumhyn August 27, 2021 12:03
@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight
Copy link
Contributor Author

Source compat failures are already known failures

@hamishknight hamishknight merged commit d3523d3 into swiftlang:main Aug 27, 2021
@hamishknight hamishknight deleted the i-understood-that-reference branch August 27, 2021 22:44
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.

2 participants