[VM] A const bool.fromEnvironment() with an explicit defaultValue of null should default to null

Closes https://github.com/dart-lang/sdk/issues/33628

Change-Id: I89ab411df0e113776364485ec9e2b6f7177dc024
Reviewed-on: https://dart-review.googlesource.com/63947
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Martin Kustermann 2018-07-06 16:26:06 +00:00 committed by commit-bot@chromium.org
parent 1a08800dd6
commit f5a3af4fcd
2 changed files with 4 additions and 3 deletions

View file

@ -47,8 +47,10 @@ class VmConstantsBackend implements ConstantsBackend {
switch (nativeName) {
case 'Bool_fromEnvironment':
final String name = (positionalArguments[0] as StringConstant).value;
final BoolConstant constant = namedArguments['defaultValue'];
final bool defaultValue = constant != null ? constant.value : false;
final Constant constant = namedArguments['defaultValue'];
final bool defaultValue = constant is BoolConstant
? constant.value
: (constant is NullConstant ? null : false);
bool value;
if (defines != null) {
value = defines[name] == 'true'

View file

@ -169,7 +169,6 @@ web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
[ $compiler == dartkp ]
class_cycle_test/02: MissingCompileTimeError
class_cycle_test/03: MissingCompileTimeError
constant_string_interpolation2_test: DartkCrash # Issue 33628
covariant_subtyping_test: RuntimeError
duplicate_implements_test/01: MissingCompileTimeError
duplicate_implements_test/02: MissingCompileTimeError