Skip to content

Commit 8aae63d

Browse files
committed
[CS] Remove null Type handling from getTypeForPattern
We should never CSGen a null Type for patterns.
1 parent 7e40c09 commit 8aae63d

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,19 +2420,12 @@ namespace {
24202420
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
24212421
bindPatternVarsOneWay);
24222422

2423-
if (!underlyingType)
2424-
return Type();
2425-
24262423
return setType(ParenType::get(CS.getASTContext(), underlyingType));
24272424
}
24282425
case PatternKind::Binding: {
24292426
auto *subPattern = cast<BindingPattern>(pattern)->getSubPattern();
24302427
auto type = getTypeForPattern(subPattern, locator,
24312428
bindPatternVarsOneWay);
2432-
2433-
if (!type)
2434-
return Type();
2435-
24362429
// Var doesn't affect the type.
24372430
return setType(type);
24382431
}
@@ -2608,9 +2601,6 @@ namespace {
26082601

26092602
Type type = TypeChecker::typeCheckPattern(contextualPattern);
26102603

2611-
if (!type)
2612-
return Type();
2613-
26142604
// Look through reference storage types.
26152605
type = type->getReferenceStorageReferent();
26162606

@@ -2627,9 +2617,6 @@ namespace {
26272617
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26282618
bindPatternVarsOneWay);
26292619

2630-
if (!subPatternType)
2631-
return Type();
2632-
26332620
// NOTE: The order here is important! Pattern matching equality is
26342621
// not symmetric (we need to fix that either by using a different
26352622
// constraint, or actually making it symmetric).
@@ -2659,9 +2646,6 @@ namespace {
26592646
locator.withPathElement(LocatorPathElt::PatternMatch(eltPattern)),
26602647
bindPatternVarsOneWay);
26612648

2662-
if (!eltTy)
2663-
return Type();
2664-
26652649
tupleTypeElts.push_back(TupleTypeElt(eltTy, tupleElt.getLabel()));
26662650
}
26672651

@@ -2676,9 +2660,6 @@ namespace {
26762660
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26772661
bindPatternVarsOneWay);
26782662

2679-
if (!subPatternType)
2680-
return Type();
2681-
26822663
return setType(OptionalType::get(subPatternType));
26832664
}
26842665

@@ -2688,7 +2669,6 @@ namespace {
26882669
const Type castType = resolveTypeReferenceInExpression(
26892670
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
26902671
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2691-
if (!castType) return Type();
26922672

26932673
// Allow `is` pattern to infer type from context which is then going
26942674
// to be propaged down to its sub-pattern via conversion. This enables
@@ -2775,9 +2755,6 @@ namespace {
27752755
TypeResolverContext::InExpression, patternMatchLoc);
27762756
}();
27772757

2778-
if (!parentType)
2779-
return Type();
2780-
27812758
// Perform member lookup into the parent's metatype.
27822759
Type parentMetaType = MetatypeType::get(parentType);
27832760
CS.addValueMemberConstraint(
@@ -2812,9 +2789,6 @@ namespace {
28122789
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
28132790
bindPatternVarsOneWay);
28142791

2815-
if (!subPatternType)
2816-
return Type();
2817-
28182792
SmallVector<AnyFunctionType::Param, 4> params;
28192793
decomposeTuple(subPatternType, params);
28202794

0 commit comments

Comments
 (0)