Files
sdk/pkg/front_end/testcases/patterns/switch_encoding.dart.weak.expect
T
Johnni Winther c6347389d2 [cfe] Move irrefutable tails into the case body
This moves pattern variable assignments of fully matched expressions into the case body. This will help backends (dart2js in particular) to reason about the code flow.

Closes #54115

Change-Id: I598a384a829f16e91ab2d6a309499cf20b9cc121
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339122
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-12-07 11:13:30 +00:00

749 lines
24 KiB
Plaintext

library;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class E extends core::_Enum /*isEnum*/ {
static const field core::List<self::E> values = #C10;
enum-element static const field self::E a = #C3;
enum-element static const field self::E b = #C6;
enum-element static const field self::E c = #C9;
const synthetic constructor •(core::int #index, core::String #name) → self::E
: super core::_Enum::•(#index, #name)
;
method _enumToString() → core::String
return "E.${this.{core::_Enum::_name}{core::String}}";
}
class PrimitiveEquals extends core::Object /*hasConstConstructor*/ {
final field core::int field;
const constructor •(core::int field) → self::PrimitiveEquals
: self::PrimitiveEquals::field = field, super core::Object::•()
;
}
class NonPrimitiveEquals extends core::Object /*hasConstConstructor*/ {
final field core::int field;
const constructor •(core::int field) → self::NonPrimitiveEquals
: self::NonPrimitiveEquals::field = field, super core::Object::•()
;
get hashCode() → core::int
return this.{self::NonPrimitiveEquals::field}{core::int}.{core::num::hashCode}{core::int};
operator ==(core::Object other) → core::bool {
if(core::identical(this, other))
return true;
return other is self::NonPrimitiveEquals && this.{self::NonPrimitiveEquals::field}{core::int} =={core::num::==}{(core::Object) → core::bool} other{self::NonPrimitiveEquals}.{self::NonPrimitiveEquals::field}{core::int};
}
}
static method switchStatement(dynamic o) → dynamic {
#L1:
{
final synthesized dynamic #0#0 = o;
synthesized core::int #0#2;
synthesized core::bool #0#2#isSet = false;
dynamic #t1;
{
lowered hoisted dynamic a#case#0;
lowered hoisted dynamic a#case#1;
if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t2 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t3 = a#case#0 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && a#case#0{dynamic}.>(5) as{TypeError} core::bool && (let final dynamic #t4 = #t1 = a#case#0 in true) || #0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t5 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C7 && (let final dynamic #t6 = a#case#1 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in true) && a#case#1{dynamic}.<(5) as{TypeError} core::bool && (let final dynamic #t7 = #t1 = a#case#1 in true)) {
dynamic a = #t1{dynamic};
{
core::print(a);
break #L1;
}
}
}
{
hoisted dynamic a;
if(#0#0 is core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t8 = a = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
}
}
}
}
}
static method switchStatementWithLabel(dynamic o) → dynamic {
#L2:
{
final synthesized dynamic #0#0 = o;
synthesized core::int #0#2;
synthesized core::bool #0#2#isSet = false;
dynamic #t9;
{
lowered hoisted dynamic a#case#0;
lowered hoisted dynamic a#case#1;
if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t10 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t11 = a#case#0 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && a#case#0{dynamic}.>(5) as{TypeError} core::bool && (let final dynamic #t12 = #t9 = a#case#0 in true) || #0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t13 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C7 && (let final dynamic #t14 = a#case#1 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in true) && a#case#1{dynamic}.<(5) as{TypeError} core::bool && (let final dynamic #t15 = #t9 = a#case#1 in true)) {
dynamic a = #t9{dynamic};
{
core::print(a);
break #L2;
}
}
}
{
hoisted dynamic a;
if(#0#0 is core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t16 = a = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
break #L2;
}
}
}
{
if(#C4 =={core::num::==}{(core::Object) → core::bool} #0#0) {
{
core::print(1);
}
}
}
}
}
static method switchStatementWithContinue(dynamic o) → dynamic {
#L3:
{
core::int #t17 = 1.{core::int::unary-}(){() → core::int};
final synthesized dynamic #0#0 = o;
synthesized core::int #0#2;
synthesized core::bool #0#2#isSet = false;
dynamic #t18;
#L4:
{
{
lowered hoisted dynamic a#case#0;
lowered hoisted dynamic a#case#1;
if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t19 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t20 = a#case#0 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && a#case#0{dynamic}.>(5) as{TypeError} core::bool && (let final dynamic #t21 = #t18 = a#case#0 in true) || #0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t22 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C7 && (let final dynamic #t23 = a#case#1 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in true) && a#case#1{dynamic}.<(5) as{TypeError} core::bool && (let final dynamic #t24 = #t18 = a#case#1 in true)) {
dynamic a = #t18{dynamic};
{
core::print(a);
break #L3;
}
}
}
{
hoisted dynamic a;
if(#0#0 is core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t25 = a = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
#t17 = 0;
break #L4;
}
}
}
{
if(#C1 =={core::num::==}{(core::Object) → core::bool} #0#0) {
{
core::print(o);
break #L3;
}
}
}
{
if(#C4 =={core::num::==}{(core::Object) → core::bool} #0#0) {
#t17 = 0;
break #L4;
}
}
{
if(#C7 =={core::num::==}{(core::Object) → core::bool} #0#0) {
#t17 = 1;
break #L4;
}
}
}
switch(#t17) /* dynamic */ {
#L5:
case #C1:
{
{
core::print(1);
continue #L6;
}
}
#L6:
case #C4:
{
{
core::print(2);
}
}
}
}
}
static method switchStatementWithContinueNested(dynamic o1, dynamic o2) → dynamic {
#L7:
{
core::int #t26 = 1.{core::int::unary-}(){() → core::int};
final synthesized dynamic #2#0 = o1;
#L8:
{
{
hoisted dynamic a;
if(#2#0 is core::List<dynamic> && #2#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t27 = a = #2#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true)) {
{
core::print(a);
break #L7;
}
}
}
{
hoisted dynamic a;
if(#2#0 is core::Map<dynamic, dynamic> && #2#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t28 = a = #2#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
#L9:
{
core::int #t29 = 1.{core::int::unary-}(){() → core::int};
final synthesized dynamic #0#0 = o2;
synthesized core::int #0#2;
synthesized core::bool #0#2#isSet = false;
dynamic #t30;
#L10:
{
{
lowered hoisted dynamic a#case#0;
lowered hoisted dynamic a#case#1;
if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t31 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t32 = a#case#0 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && a#case#0{dynamic}.>(5) as{TypeError} core::bool && (let final dynamic #t33 = #t30 = a#case#0 in true) || #0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t34 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C7 && (let final dynamic #t35 = a#case#1 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in true) && a#case#1{dynamic}.<(5) as{TypeError} core::bool && (let final dynamic #t36 = #t30 = a#case#1 in true)) {
dynamic a = #t30{dynamic};
{
core::print(a);
break #L9;
}
}
}
{
hoisted dynamic a;
if(#0#0 is core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t37 = a = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
#t26 = 1;
break #L8;
}
}
}
{
if(#C1 =={core::num::==}{(core::Object) → core::bool} #0#0) {
{
core::print(o2);
#t29 = 0;
break #L10;
}
}
}
{
if(#C4 =={core::num::==}{(core::Object) → core::bool} #0#0) {
#t29 = 0;
break #L10;
}
}
{
if(#C7 =={core::num::==}{(core::Object) → core::bool} #0#0) {
#t29 = 1;
break #L10;
}
}
}
switch(#t29) /* dynamic */ {
#L11:
case #C1:
{
{
core::print(1);
continue #L12;
}
}
#L12:
case #C4:
{
{
core::print(2);
#t26 = 0;
break #L8;
}
}
}
}
break #L7;
}
}
}
{
if(#C1 =={core::num::==}{(core::Object) → core::bool} #2#0) {
{
core::print(o1);
break #L7;
}
}
}
{
if(#C4 =={core::num::==}{(core::Object) → core::bool} #2#0) {
#t26 = 0;
break #L8;
}
}
{
if(#C7 =={core::num::==}{(core::Object) → core::bool} #2#0) {
#t26 = 1;
break #L8;
}
}
}
switch(#t26) /* dynamic */ {
#L13:
case #C1:
{
{
core::print(1);
continue #L14;
}
}
#L14:
case #C4:
{
{
core::print(2);
#L15:
{
core::int #t38 = 1.{core::int::unary-}(){() → core::int};
final synthesized dynamic #1#0 = o2;
synthesized core::int #1#2;
synthesized core::bool #1#2#isSet = false;
dynamic #t39;
#L16:
{
{
lowered hoisted dynamic a#case#0;
lowered hoisted dynamic a#case#1;
if(#1#0 is core::List<dynamic> && (#1#2#isSet ?{core::int} #1#2{core::int} : let final dynamic #t40 = #1#2#isSet = true in #1#2 = #1#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C4 && (let final dynamic #t41 = a#case#0 = #1#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && a#case#0{dynamic}.>(5) as{TypeError} core::bool && (let final dynamic #t42 = #t39 = a#case#0 in true) || #1#0 is core::List<dynamic> && (#1#2#isSet ?{core::int} #1#2{core::int} : let final dynamic #t43 = #1#2#isSet = true in #1#2 = #1#0{core::List<dynamic>}.{core::List::length}{core::int}) =={core::num::==}{(core::Object) → core::bool} #C7 && (let final dynamic #t44 = a#case#1 = #1#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in true) && a#case#1{dynamic}.<(5) as{TypeError} core::bool && (let final dynamic #t45 = #t39 = a#case#1 in true)) {
dynamic a = #t39{dynamic};
{
core::print(a);
break #L15;
}
}
}
{
hoisted dynamic a;
if(#1#0 is core::Map<dynamic, dynamic> && #1#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && (let final dynamic #t46 = a = #1#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic} in true)) {
{
core::print(a);
continue #L14;
}
}
}
{
if(#C1 =={core::num::==}{(core::Object) → core::bool} #1#0) {
{
core::print(o2);
#t38 = 0;
break #L16;
}
}
}
{
if(#C4 =={core::num::==}{(core::Object) → core::bool} #1#0) {
#t38 = 0;
break #L16;
}
}
{
if(#C7 =={core::num::==}{(core::Object) → core::bool} #1#0) {
#t38 = 1;
break #L16;
}
}
}
switch(#t38) /* dynamic */ {
#L17:
case #C1:
{
{
core::print(1);
continue #L18;
}
}
#L18:
case #C4:
{
{
core::print(2);
continue #L13;
}
}
}
}
}
}
}
}
}
static method switchStatementEnum(self::E o) → dynamic {
#L19:
switch(o) /* isExplicitlyExhaustive, self::E */ {
#L20:
case #C3:
{
core::print("a");
break #L19;
}
#L21:
case #C6:
{
core::print("b");
break #L19;
}
#L22:
case #C9:
{
core::print("c");
break #L19;
}
#L23:
default:
throw new _in::ReachabilityError::•("`null` encountered as case in a switch statement with a non-nullable type.");
}
}
static method switchStatementEnumWithGuard(self::E o) → dynamic {
#L24:
{
final synthesized self::E #0#0 = o;
{
if(#C3 =={core::Object::==}{(core::Object) → core::bool} #0#0 && true) {
{
core::print("a");
break #L24;
}
}
}
{
if(#C6 =={core::Object::==}{(core::Object) → core::bool} #0#0) {
{
core::print("b");
break #L24;
}
}
}
{
if(true) {
}
break #L24;
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch statement with a non-nullable type.");
}
}
static method switchStatementEnumWithLabel(self::E o) → dynamic {
#L25:
switch(o) /* isExplicitlyExhaustive, self::E */ {
#L26:
case #C3:
{
core::print("a");
break #L25;
}
#L27:
case #C6:
{
core::print("b");
break #L25;
}
#L28:
case #C9:
{
core::print("c");
break #L25;
}
#L29:
default:
throw new _in::ReachabilityError::•("`null` encountered as case in a switch statement with a non-nullable type.");
}
}
static method switchStatementEnumWithContinue(self::E o) → dynamic {
#L30:
switch(o) /* isExplicitlyExhaustive, self::E */ {
#L31:
case #C3:
{
core::print("a");
continue #L32;
}
#L32:
case #C6:
{
core::print("b");
continue #L33;
}
#L33:
case #C9:
{
core::print("c");
break #L30;
}
#L34:
default:
throw new _in::ReachabilityError::•("`null` encountered as case in a switch statement with a non-nullable type.");
}
}
static method switchStatementPrimitiveEquals(dynamic o) → dynamic {
#L35:
switch(o) /* dynamic */ {
#L36:
case #C11:
{
core::print("a");
break #L35;
}
#L37:
case #C12:
{
core::print("b");
}
}
}
static method switchStatementNonPrimitiveEquals(dynamic o) → dynamic {
#L38:
{
final synthesized dynamic #0#0 = o;
{
if(#C13 =={self::NonPrimitiveEquals::==}{(core::Object) → core::bool} #0#0) {
{
core::print("a");
break #L38;
}
}
}
{
if(#C14 =={self::NonPrimitiveEquals::==}{(core::Object) → core::bool} #0#0) {
{
core::print("b");
}
}
}
}
}
static method switchExpression(dynamic o) → dynamic {
return block {
dynamic #t47;
final synthesized dynamic #0#0 = o;
#L39:
{
{
hoisted dynamic a;
if(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C4) {
a = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic};
#t47 = a;
break #L39;
}
}
{
hoisted dynamic a;
if(#0#0 is core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool}) {
a = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic};
#t47 = a;
break #L39;
}
}
{
if(true) {
#t47 = null;
break #L39;
}
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t47;
}
static method switchExpressionEnum(self::E o) → dynamic {
return block {
core::int #t48;
#L40:
switch(o) /* isExplicitlyExhaustive, self::E */ {
#L41:
case #C3:
{
#t48 = 0;
break #L40;
}
#L42:
case #C6:
{
#t48 = 1;
break #L40;
}
#L43:
case #C9:
{
#t48 = 2;
break #L40;
}
#L44:
default:
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t48;
}
static method switchExpressionEnumWithGuard(self::E o) → dynamic {
return block {
core::int #t49;
final synthesized self::E #0#0 = o;
#L45:
{
{
if(#C3 =={core::Object::==}{(core::Object) → core::bool} #0#0 && true) {
#t49 = 0;
break #L45;
}
}
{
if(#C6 =={core::Object::==}{(core::Object) → core::bool} #0#0) {
#t49 = 1;
break #L45;
}
}
{
if(true) {
#t49 = 2;
break #L45;
}
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t49;
}
static method switchExpressionPrimitiveEquals(dynamic o) → dynamic {
return block {
core::int #t50;
final synthesized dynamic #0#0 = o;
#L46:
{
{
if(#C11 =={core::Object::==}{(core::Object) → core::bool} #0#0) {
#t50 = 0;
break #L46;
}
}
{
if(#C12 =={core::Object::==}{(core::Object) → core::bool} #0#0) {
#t50 = 1;
break #L46;
}
}
{
if(true) {
#t50 = 2;
break #L46;
}
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t50;
}
static method switchExpressionNonPrimitiveEquals(dynamic o) → dynamic {
return block {
core::int #t51;
final synthesized dynamic #0#0 = o;
#L47:
{
{
if(#C13 =={self::NonPrimitiveEquals::==}{(core::Object) → core::bool} #0#0) {
#t51 = 0;
break #L47;
}
}
{
if(#C14 =={self::NonPrimitiveEquals::==}{(core::Object) → core::bool} #0#0) {
#t51 = 1;
break #L47;
}
}
{
if(true) {
#t51 = 2;
break #L47;
}
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t51;
}
static method switchStatementSymbol(core::Symbol s) → dynamic {
#L48:
{
final synthesized core::Symbol #0#0 = s;
{
if(#C15 =={core::Symbol::==}{(core::Object) → core::bool} #0#0) {
{
return 0;
}
}
}
{
if(#C16 =={core::Symbol::==}{(core::Object) → core::bool} #0#0) {
{
return 1;
}
}
}
{
{
{
return 2;
}
}
}
}
}
static method switchExpressionSymbol(core::Symbol s) → dynamic {
return block {
core::int #t52;
final synthesized core::Symbol #0#0 = s;
#L49:
{
{
if(#C15 =={core::Symbol::==}{(core::Object) → core::bool} #0#0) {
#t52 = 0;
break #L49;
}
}
{
if(#C16 =={core::Symbol::==}{(core::Object) → core::bool} #0#0) {
#t52 = 1;
break #L49;
}
}
{
if(true) {
#t52 = 2;
break #L49;
}
}
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
}
} =>#t52;
}
constants {
#C1 = 0
#C2 = "a"
#C3 = self::E {index:#C1, _name:#C2}
#C4 = 1
#C5 = "b"
#C6 = self::E {index:#C4, _name:#C5}
#C7 = 2
#C8 = "c"
#C9 = self::E {index:#C7, _name:#C8}
#C10 = <self::E*>[#C3, #C6, #C9]
#C11 = self::PrimitiveEquals {field:#C1}
#C12 = self::PrimitiveEquals {field:#C4}
#C13 = self::NonPrimitiveEquals {field:#C1}
#C14 = self::NonPrimitiveEquals {field:#C4}
#C15 = #a
#C16 = #b
}
Constructor coverage from constants:
org-dartlang-testcase:///switch_encoding.dart:
- E. (from org-dartlang-testcase:///switch_encoding.dart:5:6)
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)
- PrimitiveEquals. (from org-dartlang-testcase:///switch_encoding.dart:10:9)
- NonPrimitiveEquals. (from org-dartlang-testcase:///switch_encoding.dart:16:9)