88721baf2b
This allows void typed switch expressions by allowed void typed expressions in all subexpressions inferred through the shared type analysis. This might lead to allowing void in intended places but the current approach employed by the CFE doesn't really scale so we need to revisit it anyway. In response to https://github.com/dart-lang/sdk/issues/52191 Change-Id: Iee53670d3c316764cfc1309dc76cf37bb3b03629 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299020 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
26 lines
650 B
Dart
26 lines
650 B
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
void printBugsSwitch(int n) => switch (n) {
|
|
0 => print('no bugs'),
|
|
1 => print('one bug'),
|
|
_ => print('$n bugs'),
|
|
};
|
|
|
|
void printBugsConditional(int n) => n == 0
|
|
? print('no bugs')
|
|
: n == 1
|
|
? print('one bug')
|
|
: print('$n bugs');
|
|
|
|
main() {
|
|
printBugsSwitch(0);
|
|
printBugsSwitch(1);
|
|
printBugsSwitch(2);
|
|
|
|
printBugsConditional(0);
|
|
printBugsConditional(1);
|
|
printBugsConditional(2);
|
|
}
|