Skip to content

Commit 1917239

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

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

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

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

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

@@ -2618,9 +2608,6 @@ namespace {
26182608
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26192609
bindPatternVarsOneWay);
26202610

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

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

@@ -2667,9 +2651,6 @@ namespace {
26672651
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26682652
bindPatternVarsOneWay);
26692653

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

@@ -2679,7 +2660,6 @@ namespace {
26792660
const Type castType = resolveTypeReferenceInExpression(
26802661
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
26812662
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2682-
if (!castType) return Type();
26832663

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

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

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

0 commit comments

Comments
 (0)