Files
sdk/pkg/_fe_analyzer_shared/test/exhaustiveness/data/empty.dart
T
Konstantin Shcheglov f6c4ba3748 Don't report exhaustiveness diagnostics when InvalidType is present.
This partially reverts changes made in
https://dart-review.googlesource.com/c/sdk/+/302455

Bug: https://github.com/dart-lang/sdk/issues/52151
Change-Id: I1851e170794f4777499d81fea4fb0f5c877a0bbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303084
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-15 21:54:50 +00:00

78 lines
1.4 KiB
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.
emptyBool(bool b) {
return /*
checkingOrder={bool,true,false},
error=non-exhaustive:true,
subtypes={true,false},
type=bool
*/
switch (b) {
};
}
emptyNum(num n) {
return /*
checkingOrder={num,double,int},
error=non-exhaustive:double(),
subtypes={double,int},
type=num
*/
switch (n) {
};
}
emptyInt(int i) {
return /*
error=non-exhaustive:int(),
type=int
*/
switch (i) {
};
}
enum E { a, b }
emptyEnum(E e) {
return /*
checkingOrder={E,E.a,E.b},
error=non-exhaustive:E.a,
subtypes={E.a,E.b},
type=E
*/
switch (e) {
};
}
sealed class Empty {}
emptySealed(Empty empty) => /*
checkingOrder={Empty},
type=Empty
*/
switch (empty) {
};
emptyNever(Never never) => /*type=Never*/ switch (never) { };
emptyUnresolved(
Unresolved
unresolved) => /*cfe.type=Never*/ /*analyzer.type=InvalidType*/
switch (unresolved) {
};
nonEmptyUnresolved(
Unresolved
unresolved) => /*cfe.type=Never*/ /*analyzer.type=InvalidType*/
switch (unresolved) {
_ /*cfe.space=∅*/ /*analyzer.space=InvalidType*/ => 0,
};