@@ -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.
@@ -4355,16 +4350,18 @@ bool ConstraintSystem::generateWrappedPropertyTypeConstraints(
4355
4350
static bool generateInitPatternConstraints (ConstraintSystem &cs,
4356
4351
SyntacticElementTarget target,
4357
4352
Expr *initializer) {
4358
- auto pattern = target.getInitializationPattern ();
4359
4353
auto locator = cs.getConstraintLocator (
4360
4354
initializer, LocatorPathElt::ContextualType (CTP_Initialization));
4361
- Type patternType = cs.generateConstraints (
4362
- pattern, locator, target.shouldBindPatternVarsOneWay (),
4363
- target.getInitializationPatternBindingDecl (),
4364
- target.getInitializationPatternBindingIndex ());
4365
4355
4366
- if (!patternType)
4367
- return true ;
4356
+ Type patternType;
4357
+ if (auto pattern = target.getInitializationPattern ()) {
4358
+ patternType = cs.generateConstraints (
4359
+ pattern, locator, target.shouldBindPatternVarsOneWay (),
4360
+ target.getInitializationPatternBindingDecl (),
4361
+ target.getInitializationPatternBindingIndex ());
4362
+ } else {
4363
+ patternType = cs.createTypeVariable (locator, TVO_CanBindToNoEscape);
4364
+ }
4368
4365
4369
4366
if (auto wrappedVar = target.getInitializationWrappedVar ())
4370
4367
return cs.generateWrappedPropertyTypeConstraints (
0 commit comments