From 00e481aab06d75bce3d2cf663b3ec07f5440d836 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 30 Jan 2020 23:41:19 +0000 Subject: [PATCH] [vm] Reland the flag flip behind the --nnbd build flag Bug: https://github.com/dart-lang/sdk/issues/40409 Bug: https://github.com/dart-lang/sdk/issues/40179 Change-Id: Ib84926ef15068d23dcac7b89843c454b8446b28e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134062 Reviewed-by: Siva Annamalai Commit-Queue: Liam Appelbe --- runtime/BUILD.gn | 4 ++++ runtime/vm/dart.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index f07fdc618ce..a5bdc9c61a9 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -140,6 +140,10 @@ config("dart_config") { } } + if (use_nnbd) { + defines += [ "DART_BUILT_WITH_NNBD_FLAG" ] + } + if (!is_win) { cflags = [ "-Werror", diff --git a/runtime/vm/dart.h b/runtime/vm/dart.h index 3399ca57167..c44b0cc7c83 100644 --- a/runtime/vm/dart.h +++ b/runtime/vm/dart.h @@ -123,8 +123,16 @@ class Dart : public AllStatic { static Dart_EntropySource entropy_source_callback() { return entropy_source_callback_; } + + // TODO(dartbug.com/40342): Delete these functions. static void set_non_nullable_flag(bool value) { non_nullable_flag_ = value; } - static bool non_nullable_flag() { return non_nullable_flag_; } + static bool non_nullable_flag() { +#ifdef DART_BUILT_WITH_NNBD_FLAG + return true; +#else + return non_nullable_flag_; +#endif + } private: static void WaitForIsolateShutdown();