Skip to content

Commit d2e4043

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

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
@@ -2472,19 +2472,12 @@ namespace {
24722472
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
24732473
bindPatternVarsOneWay);
24742474

2475-
if (!underlyingType)
2476-
return Type();
2477-
24782475
return setType(ParenType::get(CS.getASTContext(), underlyingType));
24792476
}
24802477
case PatternKind::Binding: {
24812478
auto *subPattern = cast<BindingPattern>(pattern)->getSubPattern();
24822479
auto type = getTypeForPattern(subPattern, locator,
24832480
bindPatternVarsOneWay);
2484-
2485-
if (!type)
2486-
return Type();
2487-
24882481
// Var doesn't affect the type.
24892482
return setType(type);
24902483
}
@@ -2666,9 +2659,6 @@ namespace {
26662659

26672660
Type type = TypeChecker::typeCheckPattern(contextualPattern);
26682661

2669-
if (!type)
2670-
return Type();
2671-
26722662
// Look through reference storage types.
26732663
type = type->getReferenceStorageReferent();
26742664

@@ -2685,9 +2675,6 @@ namespace {
26852675
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26862676
bindPatternVarsOneWay);
26872677

2688-
if (!subPatternType)
2689-
return Type();
2690-
26912678
// NOTE: The order here is important! Pattern matching equality is
26922679
// not symmetric (we need to fix that either by using a different
26932680
// constraint, or actually making it symmetric).
@@ -2717,9 +2704,6 @@ namespace {
27172704
locator.withPathElement(LocatorPathElt::PatternMatch(eltPattern)),
27182705
bindPatternVarsOneWay);
27192706

2720-
if (!eltTy)
2721-
return Type();
2722-
27232707
tupleTypeElts.push_back(TupleTypeElt(eltTy, tupleElt.getLabel()));
27242708
}
27252709

@@ -2734,9 +2718,6 @@ namespace {
27342718
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
27352719
bindPatternVarsOneWay);
27362720

2737-
if (!subPatternType)
2738-
return Type();
2739-
27402721
return setType(OptionalType::get(subPatternType));
27412722
}
27422723

@@ -2746,7 +2727,6 @@ namespace {
27462727
const Type castType = resolveTypeReferenceInExpression(
27472728
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
27482729
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2749-
if (!castType) return Type();
27502730

27512731
// Allow `is` pattern to infer type from context which is then going
27522732
// to be propaged down to its sub-pattern via conversion. This enables
@@ -2834,9 +2814,6 @@ namespace {
28342814
TypeResolverContext::InExpression, patternMatchLoc);
28352815
}();
28362816

2837-
if (!parentType)
2838-
return Type();
2839-
28402817
// Perform member lookup into the parent's metatype.
28412818
Type parentMetaType = MetatypeType::get(parentType);
28422819
CS.addValueMemberConstraint(
@@ -2871,9 +2848,6 @@ namespace {
28712848
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
28722849
bindPatternVarsOneWay);
28732850

2874-
if (!subPatternType)
2875-
return Type();
2876-
28772851
SmallVector<AnyFunctionType::Param, 4> params;
28782852
decomposeTuple(subPatternType, params);
28792853

0 commit comments

Comments
 (0)