@@ -3926,10 +3926,13 @@ bool ConstraintSystem::generateConstraints(
39263926 if (!pattern)
39273927 return true ;
39283928
3929- // Type check the pattern. Note use of `forRawPattern` here instead
3930- // of `forPatternBindingDecl` because resolved `pattern` is not
3931- // associated with `patternBinding`.
3932- auto contextualPattern = ContextualPattern::forRawPattern (pattern, dc);
3929+ // Reset binding to point to the resolved pattern. This is required
3930+ // before calling `forPatternBindingDecl`.
3931+ patternBinding->setPattern (index, pattern,
3932+ patternBinding->getInitContext (index));
3933+
3934+ auto contextualPattern =
3935+ ContextualPattern::forPatternBindingDecl (patternBinding, index);
39333936 Type patternType = TypeChecker::typeCheckPattern (contextualPattern);
39343937
39353938 // Fail early if pattern couldn't be type-checked.
@@ -3944,7 +3947,7 @@ bool ConstraintSystem::generateConstraints(
39443947
39453948 auto init = patternBinding->getInit (index);
39463949 auto target = init ? SolutionApplicationTarget::forInitialization (
3947- init, dc, patternType, pattern ,
3950+ init, dc, patternType, patternBinding, index ,
39483951 /* bindPatternVarsOneWay=*/ true )
39493952 : SolutionApplicationTarget::forUninitializedVar (
39503953 patternBinding, index, pattern, patternType);
0 commit comments