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>
85 lines
5.2 KiB
Plaintext
85 lines
5.2 KiB
Plaintext
library;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/patterns/mismatching_joint_pattern_variables.dart:12:14: Error: Variable pattern 'y' doesn't have the same type or finality in all cases.
|
|
// return y;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/mismatching_joint_pattern_variables.dart:13:14: Error: Variable pattern 'y' doesn't have the same type or finality in all cases.
|
|
// case int y || [var y] when y == 0: // Error.
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/mismatching_joint_pattern_variables.dart:15:14: Error: Variable pattern 'y' doesn't have the same type or finality in all cases.
|
|
// case int y || [final int y] when y == 0: // Error.
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/patterns/mismatching_joint_pattern_variables.dart:9:14: Error: Variable pattern 'y' doesn't have the same type or finality in all cases.
|
|
// return y;
|
|
// ^
|
|
//
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method test(dynamic x) → dynamic {
|
|
#L1:
|
|
{
|
|
final synthesized dynamic #0#0 = x;
|
|
synthesized core::bool #0#4;
|
|
synthesized core::bool #0#4#isSet = false;
|
|
synthesized dynamic #0#6;
|
|
synthesized core::bool #0#6#isSet = false;
|
|
dynamic #t1;
|
|
dynamic #t2;
|
|
{
|
|
lowered hoisted core::int y#case#0;
|
|
lowered hoisted dynamic y#case#1;
|
|
if(#0#0 is core::int && (let final dynamic #t3 = y#case#0 = #0#0{core::int} in true) && y#case#0 =={core::num::==}{(core::Object) → core::bool} 0 && (let final dynamic #t4 = #t1 = y#case#0 in true) || #0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t5 = #0#4#isSet = true in #0#4 = #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1) && (let final dynamic #t6 = y#case#1 = #0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t7 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} in true) && y#case#1 =={core::Object::==}{(core::Object) → core::bool} 0 && (let final dynamic #t8 = #t1 = y#case#1 in true)) {
|
|
core::int y = invalid-expression "pkg/front_end/testcases/patterns/mismatching_joint_pattern_variables.dart:9:14: Error: Variable pattern 'y' doesn't have the same type or finality in all cases.
|
|
return y;
|
|
^";
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
lowered hoisted core::int y#case#0;
|
|
lowered final hoisted core::int y#case#1;
|
|
if(#0#0 is core::int && (let final dynamic #t9 = y#case#0 = #0#0{core::int} in true) && y#case#0 =={core::num::==}{(core::Object) → core::bool} 0 && (let final dynamic #t10 = #t2 = y#case#0 in true) || #0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t11 = #0#4#isSet = true in #0#4 = #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 #t12 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final dynamic #t13 = y#case#1 = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t14 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true)) && y#case#1 =={core::num::==}{(core::Object) → core::bool} 0 && (let final dynamic #t15 = #t2 = y#case#1 in true)) {
|
|
core::int y = #t2{core::int};
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted invalid-type y;
|
|
if((#0#0 is core::int && (let final dynamic #t16 = y = #0#0{invalid-type} in true) || #0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t17 = #0#4#isSet = true in #0#4 = #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1) && (let final dynamic #t18 = y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t19 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} invalid-type in true)) && y =={core::Object::==}{(core::Object) → core::bool} 0) {
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
hoisted core::int y;
|
|
if((#0#0 is core::int && (let final dynamic #t20 = y = #0#0{core::int} in true) || #0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final dynamic #t21 = #0#4#isSet = true in #0#4 = #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 #t22 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int && (let final dynamic #t23 = y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t24 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int in true))) && y =={core::num::==}{(core::Object) → core::bool} 0) {
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
constants {
|
|
#C1 = 1
|
|
}
|