Skip to content
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

Add support for switch expressions in dataflow #4982

Merged
merged 47 commits into from
Dec 16, 2021

Conversation

smillst
Copy link
Member

@smillst smillst commented Dec 10, 2021

They are analyzed the same as switch statements, except that dataflow adds adds an assignment between each result expression and a dataflow-created variable at each yield statement or expression that is a result expression. The value of that dataflow-created variable is the value of the switch expression.

This includes #4978, merge that one first.

Delete SKIP-REQUIRE-JAVADOC after merging!

Fixes #2373 and fixes #4979.

@@ -0,0 +1 @@
Delete after merge.
Copy link
Member

Choose a reason for hiding this comment

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

Why is this file necessary? I don't see wide-ranging uninteresting edits in this pull request.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that NodeVisitor has 80 undocumented methods. I would have to document them all to get the Javadoc test to pass. See https://github.com/typetools/checker-framework/runs/4509004521.

* Build up the CFG for the switchTree.
*
* @return if the switch is a switch expression, then a {@link SwitchExpressionNode}; otherwise,
* null
Copy link
Member

Choose a reason for hiding this comment

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

Why is that the right thing? I guess probably because elsewhere builds all the CFG nodes for the case bodies and none is needed explicitly for the switch statement itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right. A switch statement does not have a value so it doesn't need to have a corresponding node.

@mernst mernst assigned smillst and unassigned mernst Dec 11, 2021
@smillst smillst assigned mernst and unassigned smillst Dec 13, 2021
@smillst smillst merged commit 0967219 into typetools:master Dec 16, 2021
@smillst smillst deleted the switch-expressions-dataflow branch December 16, 2021 20:54
wmdietl pushed a commit to eisop/checker-framework that referenced this pull request Dec 19, 2021
They are analyzed the same as switch statements, except that dataflow adds adds an assignment between each result expression and a dataflow-created variable at each yield statement or expression that is a result expression. The value of that dataflow-created variable is the value of the switch expression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants