Skip to content

Commit 40cc72e

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

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

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

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

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

@@ -2620,9 +2610,6 @@ namespace {
26202610
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26212611
bindPatternVarsOneWay);
26222612

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

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

@@ -2669,9 +2653,6 @@ namespace {
26692653
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26702654
bindPatternVarsOneWay);
26712655

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

@@ -2681,7 +2662,6 @@ namespace {
26812662
const Type castType = resolveTypeReferenceInExpression(
26822663
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
26832664
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2684-
if (!castType) return Type();
26852665

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

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

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

0 commit comments

Comments
 (0)