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>
54 lines
1.9 KiB
Plaintext
54 lines
1.9 KiB
Plaintext
library;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/patterns/extension_object_pattern.dart:13:27: Error: The type 'int' is not exhaustively matched by the switch cases since it doesn't match 'int(getter: double())'.
|
|
// Try adding a wildcard pattern or cases that match 'int(getter: double())'.
|
|
// method2(int i) => switch (i) /* Error */ {
|
|
// ^
|
|
//
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
extension Extension on core::int {
|
|
get getter = self::Extension|get#getter;
|
|
}
|
|
static extension-member method Extension|get#getter(lowered final core::int #this) → core::num
|
|
return #this;
|
|
static method method1(core::int i) → dynamic
|
|
return block {
|
|
core::int #t1;
|
|
final synthesized core::int #0#0 = i;
|
|
synthesized core::num #0#1;
|
|
synthesized core::bool #0#1#isSet = false;
|
|
#L1:
|
|
{
|
|
{
|
|
hoisted core::num getter;
|
|
if((#0#1#isSet ?{core::num} #0#1{core::num} : let final dynamic #t2 = #0#1#isSet = true in #0#1 = self::Extension|get#getter(#0#0)) is core::num) {
|
|
getter = #0#1#isSet ?{core::num} #0#1{core::num} : let final dynamic #t3 = #0#1#isSet = true in #0#1 = self::Extension|get#getter(#0#0);
|
|
#t1 = 0;
|
|
break #L1;
|
|
}
|
|
}
|
|
}
|
|
} =>#t1;
|
|
static method method2(core::int i) → dynamic
|
|
return block {
|
|
core::int #t4;
|
|
final synthesized core::int #0#0 = i;
|
|
synthesized core::num #0#1;
|
|
synthesized core::bool #0#1#isSet = false;
|
|
#L2:
|
|
{
|
|
{
|
|
hoisted core::int getter;
|
|
if((#0#1#isSet ?{core::num} #0#1{core::num} : let final dynamic #t5 = #0#1#isSet = true in #0#1 = self::Extension|get#getter(#0#0)) is core::int) {
|
|
getter = (#0#1#isSet ?{core::num} #0#1{core::num} : let final dynamic #t6 = #0#1#isSet = true in #0#1 = self::Extension|get#getter(#0#0)) as{Unchecked} core::int;
|
|
#t4 = 0;
|
|
break #L2;
|
|
}
|
|
}
|
|
}
|
|
} =>#t4;
|