c6347389d2
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>
291 lines
12 KiB
Plaintext
291 lines
12 KiB
Plaintext
library;
|
|
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::•()
|
|
;
|
|
abstract get b() → self::B;
|
|
abstract get i() → core::int;
|
|
}
|
|
abstract class B extends core::Object {
|
|
synthetic constructor •() → self::B
|
|
: super core::Object::•()
|
|
;
|
|
abstract get c() → self::C;
|
|
abstract get i() → core::int;
|
|
}
|
|
abstract class C extends core::Object {
|
|
synthetic constructor •() → self::C
|
|
: super core::Object::•()
|
|
;
|
|
abstract get i() → core::int;
|
|
}
|
|
static method ifCase(dynamic o) → dynamic {
|
|
{
|
|
hoisted self::A a;
|
|
final synthesized dynamic #0#0 = o;
|
|
if(#0#0 is self::A) {
|
|
a = #0#0{self::A};
|
|
{
|
|
core::print(a);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
final synthesized dynamic #1#0 = o;
|
|
if(#1#0 is self::A) {
|
|
b = #1#0{self::A}.{self::A::b}{self::B};
|
|
{
|
|
core::print(b);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::C c;
|
|
final synthesized dynamic #2#0 = o;
|
|
if(#2#0 is self::A) {
|
|
c = #2#0{self::A}.{self::A::b}{self::B}.{self::B::c}{self::C};
|
|
{
|
|
core::print(c);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted core::int i;
|
|
final synthesized dynamic #3#0 = o;
|
|
if(#3#0 is self::A) {
|
|
i = #3#0{self::A}.{self::A::b}{self::B}.{self::B::c}{self::C}.{self::C::i}{core::int};
|
|
{
|
|
core::print(i);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted core::int i;
|
|
final synthesized dynamic #4#0 = o;
|
|
if(#4#0 is self::A) {
|
|
b = #4#0{self::A}.{self::A::b}{self::B};
|
|
i = #4#0{self::A}.{self::A::i}{core::int};
|
|
{
|
|
core::print(b);
|
|
core::print(i);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
final synthesized dynamic #5#0 = o;
|
|
if(#5#0 is self::A && #C1 =={core::num::==}{(core::Object) → core::bool} #5#0{self::A}.{self::A::i}{core::int}) {
|
|
b = #5#0{self::A}.{self::A::b}{self::B};
|
|
{
|
|
core::print(b);
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
final synthesized dynamic #6#0 = o;
|
|
if(#6#0 is self::A && (let final dynamic #t1 = b = #6#0{self::A}.{self::A::b}{self::B} in true) && #C1 =={core::num::==}{(core::Object) → core::bool} #6#0{self::A}.{self::A::i}{core::int}) {
|
|
core::print(b);
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted self::C c;
|
|
final synthesized dynamic #7#0 = o;
|
|
synthesized self::B #7#2;
|
|
synthesized core::bool #7#2#isSet = false;
|
|
if(#7#0 is self::A && (let final dynamic #t2 = b = #7#2#isSet ?{self::B} #7#2{self::B} : let final dynamic #t3 = #7#2#isSet = true in #7#2 = #7#0{self::A}.{self::A::b}{self::B} in true) && #C1 =={core::num::==}{(core::Object) → core::bool} #7#0{self::A}.{self::A::i}{core::int} && ((let final dynamic #t4 = c = (#7#2#isSet ?{self::B} #7#2{self::B} : let final dynamic #t5 = #7#2#isSet = true in #7#2 = #7#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C} in true) && #C2 =={core::num::==}{(core::Object) → core::bool} (#7#2#isSet ?{self::B} #7#2{self::B} : let final dynamic #t6 = #7#2#isSet = true in #7#2 = #7#0{self::A}.{self::A::b}{self::B}).{self::B::i}{core::int})) {
|
|
core::print(b);
|
|
core::print(c);
|
|
}
|
|
}
|
|
}
|
|
static method switchExpression(dynamic o) → dynamic
|
|
return block {
|
|
core::Object? #t7;
|
|
final synthesized dynamic #0#0 = o;
|
|
synthesized self::B #0#2;
|
|
synthesized core::bool #0#2#isSet = false;
|
|
synthesized self::C #0#3;
|
|
synthesized core::bool #0#3#isSet = false;
|
|
synthesized core::int #0#5;
|
|
synthesized core::bool #0#5#isSet = false;
|
|
synthesized core::bool #0#7;
|
|
synthesized core::bool #0#7#isSet = false;
|
|
#L1:
|
|
{
|
|
{
|
|
hoisted self::A a;
|
|
if(#0#0 is self::A) {
|
|
a = #0#0{self::A};
|
|
#t7 = a;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A) {
|
|
b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t8 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B};
|
|
#t7 = b;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::C c;
|
|
if(#0#0 is self::A) {
|
|
c = #0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t9 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t10 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C};
|
|
#t7 = c;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted core::int i;
|
|
if(#0#0 is self::A) {
|
|
i = (#0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t11 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t12 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C}).{self::C::i}{core::int};
|
|
#t7 = i;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted core::int i;
|
|
if(#0#0 is self::A) {
|
|
b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t13 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B};
|
|
i = #0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t14 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int};
|
|
#t7 = "${b}${i}";
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t15 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t16 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int}))) {
|
|
b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t17 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B};
|
|
#t7 = b;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A && (let final dynamic #t18 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t19 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true) && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t20 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t21 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int}))) {
|
|
#t7 = b;
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted self::C c;
|
|
if(#0#0 is self::A && (let final dynamic #t22 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t23 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true) && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t24 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t25 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int})) && ((let final dynamic #t26 = c = #0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t27 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t28 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C} in true) && #C2 =={core::num::==}{(core::Object) → core::bool} (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t29 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::i}{core::int})) {
|
|
#t7 = "${b}${c}";
|
|
break #L1;
|
|
}
|
|
}
|
|
{
|
|
if(true) {
|
|
#t7 = null;
|
|
break #L1;
|
|
}
|
|
}
|
|
throw new _in::ReachabilityError::•("`null` encountered as case in a switch expression with a non-nullable type.");
|
|
}
|
|
} =>#t7;
|
|
static method switchStatement(dynamic o) → dynamic {
|
|
dynamic v;
|
|
#L2:
|
|
{
|
|
final synthesized dynamic #0#0 = o;
|
|
synthesized self::B #0#2;
|
|
synthesized core::bool #0#2#isSet = false;
|
|
synthesized self::C #0#3;
|
|
synthesized core::bool #0#3#isSet = false;
|
|
synthesized core::int #0#5;
|
|
synthesized core::bool #0#5#isSet = false;
|
|
synthesized core::bool #0#7;
|
|
synthesized core::bool #0#7#isSet = false;
|
|
{
|
|
hoisted self::A a;
|
|
if(#0#0 is self::A && (let final dynamic #t30 = a = #0#0{self::A} in true)) {
|
|
{
|
|
v = a;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A && (let final dynamic #t31 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t32 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true)) {
|
|
{
|
|
v = b;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::C c;
|
|
if(#0#0 is self::A && (let final dynamic #t33 = c = #0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t34 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t35 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C} in true)) {
|
|
{
|
|
v = c;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted core::int i;
|
|
if(#0#0 is self::A && (let final dynamic #t36 = i = (#0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t37 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t38 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C}).{self::C::i}{core::int} in true)) {
|
|
{
|
|
v = i;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted core::int i;
|
|
if(#0#0 is self::A && (let final dynamic #t39 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t40 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true) && (let final dynamic #t41 = i = #0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t42 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int} in true)) {
|
|
{
|
|
v = "${b}${i}";
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t43 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t44 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int})) && (let final dynamic #t45 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t46 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true)) {
|
|
{
|
|
v = b;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
if(#0#0 is self::A && (let final dynamic #t47 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t48 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true) && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t49 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t50 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int}))) {
|
|
{
|
|
v = b;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted self::B b;
|
|
hoisted self::C c;
|
|
if(#0#0 is self::A && (let final dynamic #t51 = b = #0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t52 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B} in true) && (#0#7#isSet ?{core::bool} #0#7{core::bool} : let final dynamic #t53 = #0#7#isSet = true in #0#7 = #C1 =={core::num::==}{(core::Object) → core::bool} (#0#5#isSet ?{core::int} #0#5{core::int} : let final dynamic #t54 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::i}{core::int})) && ((let final dynamic #t55 = c = #0#3#isSet ?{self::C} #0#3{self::C} : let final dynamic #t56 = #0#3#isSet = true in #0#3 = (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t57 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::c}{self::C} in true) && #C2 =={core::num::==}{(core::Object) → core::bool} (#0#2#isSet ?{self::B} #0#2{self::B} : let final dynamic #t58 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::b}{self::B}).{self::B::i}{core::int})) {
|
|
{
|
|
v = "${b}${c}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return v;
|
|
}
|
|
|
|
constants {
|
|
#C1 = 5
|
|
#C2 = 7
|
|
}
|