Skip to content

Commit 8811a22

Browse files
committed
[CS] Remove null Type handling from getTypeForPattern
We should never CSGen a null Type for patterns.
1 parent 5a90c4f commit 8811a22

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
@@ -2452,19 +2452,12 @@ namespace {
24522452
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
24532453
bindPatternVarsOneWay);
24542454

2455-
if (!underlyingType)
2456-
return Type();
2457-
24582455
return setType(ParenType::get(CS.getASTContext(), underlyingType));
24592456
}
24602457
case PatternKind::Binding: {
24612458
auto *subPattern = cast<BindingPattern>(pattern)->getSubPattern();
24622459
auto type = getTypeForPattern(subPattern, locator,
24632460
bindPatternVarsOneWay);
2464-
2465-
if (!type)
2466-
return Type();
2467-
24682461
// Var doesn't affect the type.
24692462
return setType(type);
24702463
}
@@ -2646,9 +2639,6 @@ namespace {
26462639

26472640
Type type = TypeChecker::typeCheckPattern(contextualPattern);
26482641

2649-
if (!type)
2650-
return Type();
2651-
26522642
// Look through reference storage types.
26532643
type = type->getReferenceStorageReferent();
26542644

@@ -2665,9 +2655,6 @@ namespace {
26652655
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
26662656
bindPatternVarsOneWay);
26672657

2668-
if (!subPatternType)
2669-
return Type();
2670-
26712658
// NOTE: The order here is important! Pattern matching equality is
26722659
// not symmetric (we need to fix that either by using a different
26732660
// constraint, or actually making it symmetric).
@@ -2697,9 +2684,6 @@ namespace {
26972684
locator.withPathElement(LocatorPathElt::PatternMatch(eltPattern)),
26982685
bindPatternVarsOneWay);
26992686

2700-
if (!eltTy)
2701-
return Type();
2702-
27032687
tupleTypeElts.push_back(TupleTypeElt(eltTy, tupleElt.getLabel()));
27042688
}
27052689

@@ -2714,9 +2698,6 @@ namespace {
27142698
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
27152699
bindPatternVarsOneWay);
27162700

2717-
if (!subPatternType)
2718-
return Type();
2719-
27202701
return setType(OptionalType::get(subPatternType));
27212702
}
27222703

@@ -2726,7 +2707,6 @@ namespace {
27262707
const Type castType = resolveTypeReferenceInExpression(
27272708
isPattern->getCastTypeRepr(), TypeResolverContext::InExpression,
27282709
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
2729-
if (!castType) return Type();
27302710

27312711
// Allow `is` pattern to infer type from context which is then going
27322712
// to be propaged down to its sub-pattern via conversion. This enables
@@ -2814,9 +2794,6 @@ namespace {
28142794
TypeResolverContext::InExpression, patternMatchLoc);
28152795
}();
28162796

2817-
if (!parentType)
2818-
return Type();
2819-
28202797
// Perform member lookup into the parent's metatype.
28212798
Type parentMetaType = MetatypeType::get(parentType);
28222799
CS.addValueMemberConstraint(
@@ -2851,9 +2828,6 @@ namespace {
28512828
locator.withPathElement(LocatorPathElt::PatternMatch(subPattern)),
28522829
bindPatternVarsOneWay);
28532830

2854-
if (!subPatternType)
2855-
return Type();
2856-
28572831
SmallVector<AnyFunctionType::Param, 4> params;
28582832
decomposeTuple(subPatternType, params);
28592833

0 commit comments

Comments
 (0)