Skip to content

[Sema] Eliminate duplication in CaseStmt typechecking for switch and do-catch #30879

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
Apr 9, 2020

Conversation

owenv
Copy link
Contributor

@owenv owenv commented Apr 8, 2020

Addressing review feedback on #27776

The diff is a little messy, but this is just pulling shared logic out of visitSwitchStmt and visitDoCatchStmt and into checkSiblingCaseStmts.

Comment on lines +1075 to +1082
template <typename Iterator>
void checkSiblingCaseStmts(Iterator casesBegin, Iterator casesEnd,
CaseParentKind parentKind,
bool &limitExhaustivityChecks, Type subjectType) {
static_assert(
std::is_same<typename std::iterator_traits<Iterator>::value_type,
CaseStmt *>::value,
"Expected an iterator over CaseStmt *");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there's a better way to make this work with different kinds of iterators over CaseStmt*. Switch statements vend an OptionalTransformRange instead of an ArrayRef of cases in order to support conditional compilation blocks more easily.

@owenv owenv requested a review from DougGregor April 8, 2020 14:31
@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@owenv
Copy link
Contributor Author

owenv commented Apr 9, 2020

@swift-ci please test windows platform

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