Files
sdk/pkg/front_end/testcases/patterns/variable_names.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

102 lines
6.5 KiB
Plaintext

library;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/variable_names.dart:24:23: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
// } else if (x case A(: [1, 2])) { // Error
// ^
//
// pkg/front_end/testcases/patterns/variable_names.dart:26:22: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
// } else if (x case (: [1, 2])) { // Error
// ^
//
import self as self;
import "dart:core" as core;
abstract class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
abstract get foo() → core::int?;
abstract get bar() → core::int;
abstract get baz() → core::int?;
abstract get boz() → core::num;
abstract get qux() → core::bool;
abstract get quux() → core::String;
abstract get foobar() → core::int;
}
static method test(dynamic x, dynamic y, dynamic z) → dynamic {
dynamic qux;
dynamic quux;
{
hoisted core::int foo;
hoisted core::int bar;
hoisted core::int baz;
hoisted core::double boz;
hoisted core::int foobar;
final synthesized dynamic #0#0 = x;
synthesized core::int? #0#2;
synthesized core::bool #0#2#isSet = false;
synthesized core::int? #0#5;
synthesized core::bool #0#5#isSet = false;
synthesized core::num #0#7;
synthesized core::bool #0#7#isSet = false;
if(#0#0 is self::A && (let final dynamic #t1 = (#0#2#isSet ?{core::int?} #0#2{core::int?} : let final dynamic #t2 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::foo}{core::int?})! in let final dynamic #t3 = foo = (#0#2#isSet ?{core::int?} #0#2{core::int?} : let final dynamic #t4 = #0#2#isSet = true in #0#2 = #0#0{self::A}.{self::A::foo}{core::int?})! in true) && (let final dynamic #t5 = bar = #0#0{self::A}.{self::A::bar}{core::int} in true) && !((#0#5#isSet ?{core::int?} #0#5{core::int?} : let final dynamic #t6 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::baz}{core::int?}) == null)) {
baz = (#0#5#isSet ?{core::int?} #0#5{core::int?} : let final dynamic #t7 = #0#5#isSet = true in #0#5 = #0#0{self::A}.{self::A::baz}{core::int?}) as{Unchecked} core::int;
(#0#7#isSet ?{core::num} #0#7{core::num} : let final dynamic #t8 = #0#7#isSet = true in #0#7 = #0#0{self::A}.{self::A::boz}{core::num}) as core::double;
boz = (#0#7#isSet ?{core::num} #0#7{core::num} : let final dynamic #t9 = #0#7#isSet = true in #0#7 = #0#0{self::A}.{self::A::boz}{core::num}) as core::double;
foobar = #0#0{self::A}.{self::A::foobar}{core::int};
{
return 0;
}
}
else {
hoisted dynamic foo;
hoisted dynamic bar;
hoisted dynamic baz;
hoisted core::double boz;
hoisted dynamic foobar;
final synthesized dynamic #1#0 = x;
synthesized core::Object? #1#2;
synthesized core::bool #1#2#isSet = false;
synthesized core::Object? #1#5;
synthesized core::bool #1#5#isSet = false;
synthesized core::Object? #1#7;
synthesized core::bool #1#7#isSet = false;
if(#1#0 is (core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?}) && (let final dynamic #t10 = (#1#2#isSet ?{core::Object?} #1#2{core::Object?} : let final dynamic #t11 = #1#2#isSet = true in #1#2 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foo{core::Object?})! in let final dynamic #t12 = foo = (#1#2#isSet ?{core::Object?} #1#2{core::Object?} : let final dynamic #t13 = #1#2#isSet = true in #1#2 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foo{core::Object?})! in true) && (let final dynamic #t14 = bar = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.bar{core::Object?} in true) && !((#1#5#isSet ?{core::Object?} #1#5{core::Object?} : let final dynamic #t15 = #1#5#isSet = true in #1#5 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.baz{core::Object?}) == null)) {
baz = #1#5#isSet ?{core::Object?} #1#5{core::Object?} : let final dynamic #t16 = #1#5#isSet = true in #1#5 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.baz{core::Object?};
(#1#7#isSet ?{core::Object?} #1#7{core::Object?} : let final dynamic #t17 = #1#7#isSet = true in #1#7 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.$1{core::Object?}) as core::double;
boz = (#1#7#isSet ?{core::Object?} #1#7{core::Object?} : let final dynamic #t18 = #1#7#isSet = true in #1#7 = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.$1{core::Object?}) as core::double;
foobar = #1#0{(core::Object?, {bar: core::Object?, baz: core::Object?, foo: core::Object?, foobar: core::Object?})}.foobar{core::Object?};
{
return 1;
}
}
else {
final synthesized dynamic #2#0 = x;
if(#2#0 is self::A) {
return 2;
}
else {
final synthesized dynamic #3#0 = x;
if(#3#0 is (core::Object?) && invalid-expression "pkg/front_end/testcases/patterns/variable_names.dart:26:22: Error: The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern.
} else if (x case (: [1, 2])) { // Error
^") {
return 3;
}
}
}
}
}
{
final synthesized dynamic #4#0 = y as{TypeError,ForDynamic} self::A;
if(!(#4#0 is self::A && (let final dynamic #t19 = qux = #4#0{self::A}.{self::A::qux}{core::bool} in true) && (let final dynamic #t20 = quux = #4#0{self::A}.{self::A::quux}{core::String} in true)))
throw new core::StateError::•("Pattern matching error");
}
{
final synthesized dynamic #5#0 = z as{TypeError,ForDynamic} (dynamic, {quux: dynamic});
if(!(#5#0 is (core::Object?, {quux: core::Object?}) && (let final dynamic #t21 = qux = #5#0{(core::Object?, {quux: core::Object?})}.$1{core::Object?} in true) && (let final dynamic #t22 = quux = #5#0{(core::Object?, {quux: core::Object?})}.quux{core::Object?} in true)))
throw new core::StateError::•("Pattern matching error");
}
}