Skip to content

Commit a0a9f91

Browse files
committed
[CS] Remove null Type handling from getTypeForPattern
We should never CSGen a null Type for patterns.
1 parent bca1928 commit a0a9f91

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
@@ -2412,19 +2412,12 @@ namespace {
24122412
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
24132413
bindPatternVarsOneWay);
24142414

2415-
if (!underlyingType)
2416-
return Type();
2417-
24182415
return setType(ParenType::get(CS.getASTContext(), underlyingType));
24192416
}
24202417
case PatternKind::Binding: {
24212418
auto *subPattern = cast<BindingPattern>(pattern)->getSubPattern();
24222419
auto type = getTypeForPattern(subPattern, locator,
24232420
bindPatternVarsOneWay);
2424-
2425-
if (!type)
2426-
return Type();
2427-
24282421
// Var doesn't affect the type.
24292422
return setType(type);
24302423
}
@@ -2600,9 +2593,6 @@ namespace {
26002593

26012594
Type type = TypeChecker::typeCheckPattern(contextualPattern);
26022595

2603-
if (!type)
2604-
return Type();
2605-
26062596
// Look through reference storage types.
26072597
type = type->getReferenceStorageReferent();
26082598

@@ -2619,9 +2609,6 @@ namespace {
26192609
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26202610
bindPatternVarsOneWay);
26212611

2622-
if (!subPatternType)
2623-
return Type();
2624-
26252612
// NOTE: The order here is important! Pattern matching equality is
26262613
// not symmetric (we need to fix that either by using a different
26272614
// constraint, or actually making it symmetric).
@@ -2651,9 +2638,6 @@ namespace {
26512638
locator.withPathElement(LocatorPathElt::PatternMatch(eltPattern)),
26522639
bindPatternVarsOneWay);
26532640

2654-
if (!eltTy)
2655-
return Type();
2656-
26572641
tupleTypeElts.push_back(TupleTypeElt(eltTy, tupleElt.getLabel()));
26582642
}
26592643

@@ -2668,9 +2652,6 @@ namespace {
26682652
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26692653
bindPatternVarsOneWay);
26702654

2671-
if (!subPatternType)
2672-
return Type();
2673-
26742655
return setType(OptionalType::get(subPatternType));
26752656
}
26762657

@@ -2680,7 +2661,6 @@ namespace {
26802661
const Type castType = resolveTypeReferenceInExpression(
26812662
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
26822663
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2683-
if (!castType) return Type();
26842664

26852665
// Allow `is` pattern to infer type from context which is then going
26862666
// to be propaged down to its sub-pattern via conversion. This enables
@@ -2767,9 +2747,6 @@ namespace {
27672747
TypeResolverContext::InExpression, patternMatchLoc);
27682748
}();
27692749

2770-
if (!parentType)
2771-
return Type();
2772-
27732750
// Perform member lookup into the parent's metatype.
27742751
Type parentMetaType = MetatypeType::get(parentType);
27752752
CS.addValueMemberConstraint(
@@ -2804,9 +2781,6 @@ namespace {
28042781
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
28052782
bindPatternVarsOneWay);
28062783

2807-
if (!subPatternType)
2808-
return Type();
2809-
28102784
SmallVector<AnyFunctionType::Param, 4> params;
28112785
decomposeTuple(subPatternType, params);
28122786

0 commit comments

Comments
 (0)