@@ -2447,12 +2447,7 @@ namespace {
2447
2447
bool bindPatternVarsOneWay,
2448
2448
PatternBindingDecl *patternBinding = nullptr ,
2449
2449
unsigned patternBindingIndex = 0 ) {
2450
- // If there's no pattern, then we have an unknown subpattern. Create a
2451
- // type variable.
2452
- if (!pattern) {
2453
- return CS.createTypeVariable (CS.getConstraintLocator (locator),
2454
- TVO_CanBindToNoEscape);
2455
- }
2450
+ assert (pattern);
2456
2451
2457
2452
// Local function that must be called for each "return" throughout this
2458
2453
// function, to set the type of the pattern.
@@ -4365,16 +4360,18 @@ bool ConstraintSystem::generateWrappedPropertyTypeConstraints(
4365
4360
static bool generateInitPatternConstraints (ConstraintSystem &cs,
4366
4361
SyntacticElementTarget target,
4367
4362
Expr *initializer) {
4368
- auto pattern = target.getInitializationPattern ();
4369
4363
auto locator = cs.getConstraintLocator (
4370
4364
initializer, LocatorPathElt::ContextualType (CTP_Initialization));
4371
- Type patternType = cs.generateConstraints (
4372
- pattern, locator, target.shouldBindPatternVarsOneWay (),
4373
- target.getInitializationPatternBindingDecl (),
4374
- target.getInitializationPatternBindingIndex ());
4375
4365
4376
- if (!patternType)
4377
- return true ;
4366
+ Type patternType;
4367
+ if (auto pattern = target.getInitializationPattern ()) {
4368
+ patternType = cs.generateConstraints (
4369
+ pattern, locator, target.shouldBindPatternVarsOneWay (),
4370
+ target.getInitializationPatternBindingDecl (),
4371
+ target.getInitializationPatternBindingIndex ());
4372
+ } else {
4373
+ patternType = cs.createTypeVariable (locator, TVO_CanBindToNoEscape);
4374
+ }
4378
4375
4379
4376
if (auto wrappedVar = target.getInitializationWrappedVar ())
4380
4377
return cs.generateWrappedPropertyTypeConstraints (
0 commit comments