Skip to content

Commit ffe7607

Browse files
committed
[CS] Remove null pattern handling from getTypeForPattern
Push the only null case that can occur up into the caller.
1 parent ff77daa commit ffe7607

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/Sema/CSGen.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,12 +2447,7 @@ namespace {
24472447
bool bindPatternVarsOneWay,
24482448
PatternBindingDecl *patternBinding = nullptr,
24492449
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);
24562451

24572452
// Local function that must be called for each "return" throughout this
24582453
// function, to set the type of the pattern.
@@ -4355,16 +4350,18 @@ bool ConstraintSystem::generateWrappedPropertyTypeConstraints(
43554350
static bool generateInitPatternConstraints(ConstraintSystem &cs,
43564351
SyntacticElementTarget target,
43574352
Expr *initializer) {
4358-
auto pattern = target.getInitializationPattern();
43594353
auto locator = cs.getConstraintLocator(
43604354
initializer, LocatorPathElt::ContextualType(CTP_Initialization));
4361-
Type patternType = cs.generateConstraints(
4362-
pattern, locator, target.shouldBindPatternVarsOneWay(),
4363-
target.getInitializationPatternBindingDecl(),
4364-
target.getInitializationPatternBindingIndex());
43654355

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+
}
43684365

43694366
if (auto wrappedVar = target.getInitializationWrappedVar())
43704367
return cs.generateWrappedPropertyTypeConstraints(

0 commit comments

Comments
 (0)