Files
sdk/pkg/front_end/testcases/patterns/switchExpression_empty.dart.weak.expect
T
Johnni Winther 5518abf1c7 [_fe_analyzer_shared] Update non-exhaustive message
This updates the message report for non-exhaustive switch statements
and expressions to include the witness in the problem message and
a reduced witness, which doesn't include properties that fully cover the
static type. The message is also split into two messages; one for
switch statements and one for switch expressions, allowing for a
better wording regarding the default/wildcard pattern case.

Change-Id: I17db657ef12ade5d47fa96bf69b8807e33ed5b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-04-04 09:44:59 +00:00

23 lines
838 B
Plaintext

library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/switchExpression_empty.dart:5:16: Error: The type 'dynamic' is not exhaustively matched by the switch cases since it doesn't match 'Object()'.
// Try adding a wildcard pattern or cases that match 'Object()'.
// f(x) => switch(x) {};
// ^
//
import self as self;
import "dart:_internal" as _in;
static method f(dynamic x) → dynamic
return let final Never #t1 = block {
Never #t2;
#L1:
switch(x) /*isExplicitlyExhaustive*/ {
#L2:
default:
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t2 in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");