Files
sdk/pkg/front_end/testcases/nnbd/switch_redesign_fall_over.dart.weak.expect
T
Johnni Winther 2414b293e1 [cfe] Throw error on exhaustive switch and expression of type Never
This requires a change to flow analysis that does not promote
expressions to Never through is-tests and equality tests.

Change-Id: Iec2ba5b78e61d205ad21dad6f07dbdb25fc746d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163380
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-09-25 08:35:03 +00:00

59 lines
1.3 KiB
Plaintext

library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/nnbd/switch_redesign_fall_over.dart:23:5: Error: Switch case may fall through to the next case.
// case -42: // Error.
// ^
//
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
method foo(core::int x, core::bool b) → dynamic {
switch(x) {
#L1:
case #C1:
{
let final Never #t1 = this.{self::A::neverReturn}() in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
}
#L2:
default:
{
self::bar();
}
}
}
abstract method neverReturn() → Never;
}
static method bar() → dynamic {}
static method foo(core::int x, core::bool b) → dynamic {
switch(x) {
#L3:
case #C1:
{
let final Never #t2 = b ?{Never} throw "hest" : throw "fisk" in throw new _in::ReachabilityError::•("`null` encountered as the result from expression with type `Never`.");
}
#L4:
case #C2:
{
self::bar();
}
#L5:
default:
{
self::bar();
}
}
}
static method main() → dynamic {}
constants {
#C1 = 42
#C2 = -42
}