@@ -2387,12 +2387,7 @@ namespace {
2387
2387
bool bindPatternVarsOneWay,
2388
2388
PatternBindingDecl *patternBinding = nullptr ,
2389
2389
unsigned patternBindingIndex = 0 ) {
2390
- // If there's no pattern, then we have an unknown subpattern. Create a
2391
- // type variable.
2392
- if (!pattern) {
2393
- return CS.createTypeVariable (CS.getConstraintLocator (locator),
2394
- TVO_CanBindToNoEscape);
2395
- }
2390
+ assert (pattern);
2396
2391
2397
2392
// Local function that must be called for each "return" throughout this
2398
2393
// function, to set the type of the pattern.
@@ -4232,16 +4227,18 @@ bool ConstraintSystem::generateWrappedPropertyTypeConstraints(
4232
4227
static bool generateInitPatternConstraints (ConstraintSystem &cs,
4233
4228
SyntacticElementTarget target,
4234
4229
Expr *initializer) {
4235
- auto pattern = target.getInitializationPattern ();
4236
4230
auto locator = cs.getConstraintLocator (
4237
4231
initializer, LocatorPathElt::ContextualType (CTP_Initialization));
4238
- Type patternType = cs.generateConstraints (
4239
- pattern, locator, target.shouldBindPatternVarsOneWay (),
4240
- target.getInitializationPatternBindingDecl (),
4241
- target.getInitializationPatternBindingIndex ());
4242
4232
4243
- if (!patternType)
4244
- return true ;
4233
+ Type patternType;
4234
+ if (auto pattern = target.getInitializationPattern ()) {
4235
+ patternType = cs.generateConstraints (
4236
+ pattern, locator, target.shouldBindPatternVarsOneWay (),
4237
+ target.getInitializationPatternBindingDecl (),
4238
+ target.getInitializationPatternBindingIndex ());
4239
+ } else {
4240
+ patternType = cs.createTypeVariable (locator, TVO_CanBindToNoEscape);
4241
+ }
4245
4242
4246
4243
if (auto wrappedVar = target.getInitializationWrappedVar ())
4247
4244
return cs.generateWrappedPropertyTypeConstraints (
0 commit comments