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