Skip to content

[AST] Add a pointer to parent statement in 'CaseStmt' #32444

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 24, 2020

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 17, 2020

So that clients can easily get SwitchStmt or DoCatchStmt from a CaseStmt.

This is a preparation for on-demand VarDecl type checking in CaseStmt patterns. Similar to patterns in if/guard conditions, we want to type check VarDecl in switch/do-catch statement on demand.

@rintaro
Copy link
Member Author

rintaro commented Jun 17, 2020

@swift-ci Please smoke test

@rintaro rintaro requested a review from DougGregor June 17, 2020 21:53
@DougGregor
Copy link
Member

Hrm. I support this is okay, but I wonder---could we instead ask ASTScope to provide this information for us, rather than add parent pointers each place we need to do this?

@rintaro
Copy link
Member Author

rintaro commented Jun 17, 2020

Hm, interesting. Unfortunately, ASTScope is still disabled in code completion so far. I'll see if we can enable it soon.

@rintaro
Copy link
Member Author

rintaro commented Jun 17, 2020

FWIW, only another place we want to add a parent pointer is a reference to TapExpr in VarDecl. Since VarDecl already have a pointer union to the parent PatternBindingDecl, VarDecl or Stmt, we can easily add Expr * to the union.

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.

Okay, this is fine. I'd forgotten that ASTScope was not enabled in code completion. If we fix that, we can delete a nice pile of code.

@rintaro rintaro merged commit 7bddcb1 into swiftlang:master Jun 24, 2020
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