[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>
diff --git a/pkg/kernel/lib/vm/constants_native_effects.dart b/pkg/kernel/lib/vm/constants_native_effects.dart
index 3678749..6566547 100644
--- a/pkg/kernel/lib/vm/constants_native_effects.dart
+++ b/pkg/kernel/lib/vm/constants_native_effects.dart
@@ -47,8 +47,10 @@
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'
diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status
index af6e7d3..9bf1bcbc 100644
--- a/tests/language_2/language_2_kernel.status
+++ b/tests/language_2/language_2_kernel.status
@@ -169,7 +169,6 @@
[ $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