@@ -3926,10 +3926,13 @@ bool ConstraintSystem::generateConstraints(
3926
3926
if (!pattern)
3927
3927
return true ;
3928
3928
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);
3933
3936
Type patternType = TypeChecker::typeCheckPattern (contextualPattern);
3934
3937
3935
3938
// Fail early if pattern couldn't be type-checked.
@@ -3944,7 +3947,7 @@ bool ConstraintSystem::generateConstraints(
3944
3947
3945
3948
auto init = patternBinding->getInit (index);
3946
3949
auto target = init ? SolutionApplicationTarget::forInitialization (
3947
- init, dc, patternType, pattern ,
3950
+ init, dc, patternType, patternBinding, index ,
3948
3951
/* bindPatternVarsOneWay=*/ true )
3949
3952
: SolutionApplicationTarget::forUninitializedVar (
3950
3953
patternBinding, index, pattern, patternType);
0 commit comments