85cb56dd20
This changes the pattern matching lowering to avoid using late final variables (or lowerings thereof) and instead inline the initializer where used. This avoids generating closures that are hard for backends to reason about and optimize. Closes #52805 Closes #53804 Change-Id: Ia887446dd4d4475d05cf852c812bfe4b851de261 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338860 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
51 lines
1.5 KiB
Plaintext
51 lines
1.5 KiB
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method test(dynamic x) → dynamic {
|
|
#L1:
|
|
{
|
|
final synthesized dynamic #0#0 = x;
|
|
synthesized dynamic #0#6;
|
|
synthesized core::bool #0#6#isSet = false;
|
|
{
|
|
hoisted core::int y;
|
|
if(#0#0 is core::int && (let final dynamic #t1 = y = #0#0{core::int} in true)) {
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted core::double z;
|
|
if(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && ((#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t2 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::double && (let final dynamic #t3 = z = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t4 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::double in true))) {
|
|
{
|
|
return z;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static method main() → dynamic {
|
|
self::expectEquals(self::test(0), 0);
|
|
self::expectEquals(self::test(<core::double>[3.14]), 3.14);
|
|
self::expectEquals(self::test("foo"), null);
|
|
self::expectEquals(self::test(null), null);
|
|
}
|
|
static method expectEquals(dynamic x, dynamic y) → dynamic {
|
|
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) {
|
|
throw "Expected ${x} to be equal to ${y}.";
|
|
}
|
|
}
|
|
|
|
constants {
|
|
#C1 = 1
|
|
}
|