5493d42be3
This adds thrown exception in weak-mode for exhaustive switch expressions and statements to catch the unsound `null` values. Closes #51769 Closes #51053 Change-Id: Ieb89e65f51e84853510fc320b64db01a80a262ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289600 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
27 lines
597 B
Plaintext
27 lines
597 B
Plaintext
library /*isNonNullableByDefault*/;
|
|
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(#0#0 is{ForNonNullableByDefault} core::int) {
|
|
#t1 = 0;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
if(true) {
|
|
#t1 = 1;
|
|
break #L1;
|
|
}
|
|
}
|
|
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
|
|
}
|
|
} =>#t1;
|