@@ -2427,12 +2427,7 @@ namespace {
2427
2427
bool bindPatternVarsOneWay,
2428
2428
PatternBindingDecl *patternBinding = nullptr ,
2429
2429
unsigned patternBindingIndex = 0 ) {
2430
- // If there's no pattern, then we have an unknown subpattern. Create a
2431
- // type variable.
2432
- if (!pattern) {
2433
- return CS.createTypeVariable (CS.getConstraintLocator (locator),
2434
- TVO_CanBindToNoEscape);
2435
- }
2430
+ assert (pattern);
2436
2431
2437
2432
// Local function that must be called for each "return" throughout this
2438
2433
// function, to set the type of the pattern.
@@ -4335,16 +4330,18 @@ bool ConstraintSystem::generateWrappedPropertyTypeConstraints(
4335
4330
static bool generateInitPatternConstraints (ConstraintSystem &cs,
4336
4331
SyntacticElementTarget target,
4337
4332
Expr *initializer) {
4338
- auto pattern = target.getInitializationPattern ();
4339
4333
auto locator = cs.getConstraintLocator (
4340
4334
initializer, LocatorPathElt::ContextualType (CTP_Initialization));
4341
- Type patternType = cs.generateConstraints (
4342
- pattern, locator, target.shouldBindPatternVarsOneWay (),
4343
- target.getInitializationPatternBindingDecl (),
4344
- target.getInitializationPatternBindingIndex ());
4345
4335
4346
- if (!patternType)
4347
- return true ;
4336
+ Type patternType;
4337
+ if (auto pattern = target.getInitializationPattern ()) {
4338
+ patternType = cs.generateConstraints (
4339
+ pattern, locator, target.shouldBindPatternVarsOneWay (),
4340
+ target.getInitializationPatternBindingDecl (),
4341
+ target.getInitializationPatternBindingIndex ());
4342
+ } else {
4343
+ patternType = cs.createTypeVariable (locator, TVO_CanBindToNoEscape);
4344
+ }
4348
4345
4349
4346
if (auto wrappedVar = target.getInitializationWrappedVar ())
4350
4347
return cs.generateWrappedPropertyTypeConstraints (
0 commit comments