5518abf1c7
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>
29 lines
815 B
Plaintext
29 lines
815 B
Plaintext
library /*isNonNullableByDefault*/;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/patterns/switchExpression_onePattern_guarded.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:core" as core;
|
|
import "dart:_internal" as _in;
|
|
|
|
static method f(dynamic x) → dynamic
|
|
return block {
|
|
core::int #t1;
|
|
final synthesized dynamic #0#0 = x;
|
|
#L1:
|
|
{
|
|
{
|
|
if(true && true) {
|
|
#t1 = 0;
|
|
break #L1;
|
|
}
|
|
}
|
|
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
|
|
}
|
|
} =>#t1;
|