Files
sdk/pkg/front_end/testcases/patterns/switchExpression_twoPatterns.dart.weak.expect
T
Johnni Winther 5493d42be3 [cfe] Throw error for null in non-nullable switch in weak mode
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>
2023-03-22 10:30:24 +00:00

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;