@@ -319,38 +319,6 @@ namespace {
319
319
return TypeAndVal.getInt ();
320
320
}
321
321
322
- // Defines a "usefulness" metric that returns whether the given space
323
- // contributes meaningfully to the exhaustiveness of a pattern.
324
- bool isUseful () const {
325
- auto subspacesUseful = [](const Space &space) {
326
- for (auto &subspace : space.getSpaces ()) {
327
- if (!subspace.isUseful ()) {
328
- return false ;
329
- }
330
- }
331
- return true ;
332
- };
333
-
334
- switch (getKind ()) {
335
- case SpaceKind::Empty:
336
- return false ;
337
- case SpaceKind::Type:
338
- case SpaceKind::BooleanConstant:
339
- case SpaceKind::UnknownCase:
340
- return true ;
341
- case SpaceKind::Disjunct:
342
- if (getSpaces ().empty ()) {
343
- return false ;
344
- }
345
- return subspacesUseful (*this );
346
- case SpaceKind::Constructor:
347
- if (getSpaces ().empty ()) {
348
- return true ;
349
- }
350
- return subspacesUseful (*this );
351
- }
352
- }
353
-
354
322
// An optimization that computes if the difference of this space and
355
323
// another space is empty.
356
324
bool isSubspace (const Space &other, TypeChecker &TC,
@@ -1178,13 +1146,14 @@ namespace {
1178
1146
Space projection = projectPattern (TC, caseItem.getPattern (),
1179
1147
sawDowngradablePattern);
1180
1148
1181
- if (projection.isUseful ()
1182
- && projection.isSubspace (Space::forDisjunct (spaces), TC, DC)) {
1149
+ if (! projection.isEmpty () &&
1150
+ projection.isSubspace (Space::forDisjunct (spaces), TC, DC)) {
1183
1151
sawRedundantPattern |= true ;
1184
1152
1185
1153
TC.diagnose (caseItem.getStartLoc (),
1186
1154
diag::redundant_particular_case)
1187
1155
.highlight (caseItem.getSourceRange ());
1156
+ continue ;
1188
1157
} else {
1189
1158
Expr *cachedExpr = nullptr ;
1190
1159
if (checkRedundantLiteral (caseItem.getPattern (), cachedExpr)) {
@@ -1195,6 +1164,7 @@ namespace {
1195
1164
TC.diagnose (cachedExpr->getLoc (),
1196
1165
diag::redundant_particular_literal_case_here)
1197
1166
.highlight (cachedExpr->getSourceRange ());
1167
+ continue ;
1198
1168
}
1199
1169
}
1200
1170
spaces.push_back (projection);
0 commit comments