Skip to content

Commit

Permalink
Delete unreachable default clauses. (#3209)
Browse files Browse the repository at this point in the history
The Dart analyzer will soon be changed so that if the `default` clause
of a `switch` statement is determined to be unreachable by the
exhaustiveness checker, a new warning of type
`unreachable_switch_default` will be issued. This parallels the
behavior of the existing `unreachable_switch_case` warning, which is
issued whenever a `case` clause of a `switch` statement is determined
to be unreachable. For details see
dart-lang/sdk#54575.

This PR deletes unreachable `default` clauses from `drift` now,
to avoid spurious warnings when the analyzer change lands.
---------

Co-authored-by: Simon Binder <[email protected]>
  • Loading branch information
stereotype441 and simolus3 authored Sep 9, 2024
1 parent 74af262 commit 5e8b254
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
4 changes: 0 additions & 4 deletions drift/lib/src/runtime/executor/helpers/engines.dart
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,12 @@ class DelegatedDatabase extends _BaseExecutor {
@override
// ignore: library_private_types_in_public_api
TransactionExecutor beginTransactionInContext(_BaseExecutor context) {
final transactionDelegate = delegate.transactionDelegate;

switch (delegate.transactionDelegate) {
case NoTransactionDelegate noTransactionDelegate:
return _StatementBasedTransactionExecutor(
this, context, noTransactionDelegate);
case SupportedTransactionDelegate supported:
return _WrappingTransactionExecutor(this, supported);
default:
throw StateError('Unknown transaction delegate: $transactionDelegate');
}
}

Expand Down
3 changes: 0 additions & 3 deletions sqlparser/lib/utils/node_to_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ class NodeSqlBuilder extends AstVisitor<void, void> {
keyword(TokenType.instead);
keyword(TokenType.of);
break;
default:
// Can happen if e.mode == null
break;
}

visit(e.target, arg);
Expand Down

0 comments on commit 5e8b254

Please sign in to comment.