3175e427d8
Note: Const locals are still off for VM aot and dart2js for the entry points I've found in an attempt to retain the old behaviour there. It might be better if those targets could remove such locals in a whole-world analysis instead. * Keep const locals by default (except as noted above). Update the verifier to accept that. For the platforms this has increased the size by at most 6584 bytes. With this the VM will pass in any const locals as it does normal locals, but as the variable is never captured it will never pass a const local defined in a method when inside a local function in that method. * Change the dart scope calculation(s) to return the found variables instead of just the types of the found variables. * When the incremental compilers expression compilation - via the dart scope calculation - finds a const local that it wasn't told about, it will pass it on as an extra variable that it knows about, allowing for evaluating const locals in the case not covered by the first bullet. With luck this can in future CLs be extended to know about other variables that we're not told about, allowing to give a message saying something like "yes, we know what 'foo' is, but you can't currently use it" as wanted in for instance https://github.com/dart-lang/sdk/issues/60316 and https://github.com/dart-lang/sdk/issues/53996. Tested: Existing tests for existing functionality; new tests for the new Change-Id: I1ec24350273e6f81574bb2888f6bf46e3b8b1b47 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445461 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
20 lines
1.0 KiB
Plaintext
20 lines
1.0 KiB
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method f(dynamic x) → dynamic {
|
|
hoisted has-declared-initializer dynamic a;
|
|
{
|
|
final synthesized dynamic #0#0 = x as{TypeError,ForDynamic} core::Map<dynamic, dynamic>;
|
|
synthesized dynamic #0#4;
|
|
synthesized core::bool #0#4#isSet = false;
|
|
final const synthesized core::String #0#2 = #C1;
|
|
if(!(#0#0 is core::Map<dynamic, dynamic> && (!((#0#4#isSet ?{dynamic} #0#4 : let final dynamic #t1 = #0#4#isSet = true in #0#4 = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C1){(core::Object?) → dynamic}) == null) || null is dynamic && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool}) && (let final dynamic #t2 = a = #0#4#isSet ?{dynamic} #0#4 : let final dynamic #t3 = #0#4#isSet = true in #0#4 = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C1){(core::Object?) → dynamic} in true)))
|
|
throw{for-error-handling} new core::StateError::•("Pattern matching error");
|
|
}
|
|
}
|
|
|
|
constants {
|
|
#C1 = "a"
|
|
}
|