@@ -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-
48584784ConstraintSystem::TypeMatchResult
48594785ConstraintSystem::applyPropertyWrapperToParameter (
48604786 Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
0 commit comments