Skip to content

Commit dcd5340

Browse files
authored
Merge pull request #64455 from xedin/remove-generate-constraints-casestmt
[ConstraintSystem] NFC: Remove obsolete `generateConstraints(CaseStmt *, ...)`
2 parents 095d84d + c19de06 commit dcd5340

File tree

2 files changed

+0
-85
lines changed

2 files changed

+0
-85
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4298,17 +4298,6 @@ class ConstraintSystem {
42984298
[[nodiscard]]
42994299
bool generateConstraints(StmtCondition condition, DeclContext *dc);
43004300

4301-
/// Generate constraints for a case statement.
4302-
///
4303-
/// \param subjectType The type of the "subject" expression in the enclosing
4304-
/// switch statement.
4305-
///
4306-
/// \returns true if there was an error in constraint generation, false
4307-
/// if generation succeeded.
4308-
[[nodiscard]]
4309-
bool generateConstraints(CaseStmt *caseStmt, DeclContext *dc,
4310-
Type subjectType, ConstraintLocator *locator);
4311-
43124301
/// Generate constraints for a given set of overload choices.
43134302
///
43144303
/// \param constraints The container of generated constraint choices.

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,80 +4781,6 @@ bool ConstraintSystem::generateConstraints(StmtCondition condition,
47814781
return false;
47824782
}
47834783

4784-
bool ConstraintSystem::generateConstraints(
4785-
CaseStmt *caseStmt, DeclContext *dc, Type subjectType,
4786-
ConstraintLocator *locator) {
4787-
// Pre-bind all of the pattern variables within the case.
4788-
bindSwitchCasePatternVars(dc, caseStmt);
4789-
4790-
for (auto &caseLabelItem : caseStmt->getMutableCaseLabelItems()) {
4791-
// Resolve the pattern.
4792-
auto *pattern = caseLabelItem.getPattern();
4793-
if (!caseLabelItem.isPatternResolved()) {
4794-
pattern = TypeChecker::resolvePattern(
4795-
pattern, dc, /*isStmtCondition=*/false);
4796-
if (!pattern)
4797-
return true;
4798-
}
4799-
4800-
// Generate constraints for the pattern, including one-way bindings for
4801-
// any variables that show up in this pattern, because those variables
4802-
// can be referenced in the guard expressions and the body.
4803-
Type patternType = generateConstraints(
4804-
pattern, locator, /* bindPatternVarsOneWay=*/true,
4805-
/*patternBinding=*/nullptr, /*patternBindingIndex=*/0);
4806-
4807-
// Convert the subject type to the pattern, which establishes the
4808-
// bindings.
4809-
addConstraint(
4810-
ConstraintKind::Conversion, subjectType, patternType, locator);
4811-
4812-
// Generate constraints for the guard expression, if there is one.
4813-
Expr *guardExpr = caseLabelItem.getGuardExpr();
4814-
if (guardExpr) {
4815-
auto &ctx = dc->getASTContext();
4816-
SyntacticElementTarget guardTarget(
4817-
guardExpr, dc, CTP_Condition, ctx.getBoolType(), /*discarded*/ false);
4818-
4819-
if (generateConstraints(guardTarget))
4820-
return true;
4821-
4822-
guardExpr = guardTarget.getAsExpr();
4823-
setTargetFor(guardExpr, guardTarget);
4824-
}
4825-
4826-
// Save this info.
4827-
setCaseLabelItemInfo(&caseLabelItem, {pattern, guardExpr});
4828-
4829-
// For any pattern variable that has a parent variable (i.e., another
4830-
// pattern variable with the same name in the same case), require that
4831-
// the types be equivalent.
4832-
pattern->forEachNode([&](Pattern *pattern) {
4833-
auto namedPattern = dyn_cast<NamedPattern>(pattern);
4834-
if (!namedPattern)
4835-
return;
4836-
4837-
auto var = namedPattern->getDecl();
4838-
if (auto parentVar = var->getParentVarDecl()) {
4839-
addConstraint(
4840-
ConstraintKind::Equal, getType(parentVar), getType(var),
4841-
getConstraintLocator(
4842-
locator,
4843-
LocatorPathElt::PatternMatch(namedPattern)));
4844-
}
4845-
});
4846-
}
4847-
4848-
// Bind the types of the case body variables.
4849-
for (auto caseBodyVar : caseStmt->getCaseBodyVariablesOrEmptyArray()) {
4850-
auto parentVar = caseBodyVar->getParentVarDecl();
4851-
assert(parentVar && "Case body variables always have parents");
4852-
setType(caseBodyVar, getType(parentVar));
4853-
}
4854-
4855-
return false;
4856-
}
4857-
48584784
ConstraintSystem::TypeMatchResult
48594785
ConstraintSystem::applyPropertyWrapperToParameter(
48604786
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,

0 commit comments

Comments
 (0)