13c4ad23c5
This adds the static type of the switch statement expression to the AST to better support optimizations based on the possible runtime values of the switch expression. TEST=existing Change-Id: Ief35b687150401100d8c96721a026e9f0911b3b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301063 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
23 lines
849 B
Plaintext
23 lines
849 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, dynamic */ {
|
|
#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`.");
|