[dart2js] Replace references to NNBD with null safety.
Change-Id: Id23dce928425c99770ced629f866cee01fa2ef0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212240
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
index fdb24b7..496393a 100644
--- a/pkg/compiler/lib/src/elements/types.dart
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -1707,7 +1707,7 @@
DartType nullableType(DartType baseType) {
bool _isNullable(DartType t) =>
- // Note that we can assume NNBD is enabled here.
+ // Note that we can assume null safety is enabled here.
t.isNull ||
t is NullableType ||
t is LegacyType && _isNullable(t.baseType) ||
diff --git a/pkg/compiler/lib/src/js_backend/specialized_checks.dart b/pkg/compiler/lib/src/js_backend/specialized_checks.dart
index 431ebe7..9a887aa 100644
--- a/pkg/compiler/lib/src/js_backend/specialized_checks.dart
+++ b/pkg/compiler/lib/src/js_backend/specialized_checks.dart
@@ -72,8 +72,8 @@
}
DartTypes dartTypes = closedWorld.dartTypes;
- // Top types (here it could be Object in non-NNBD mode) should be constant
- // folded outside the specializer. This test protects logic below.
+ // Top types should be constant folded outside the specializer. This test
+ // protects logic below.
if (dartTypes.isTopType(dartType)) return null;
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
if (!dartTypes.isSubtype(
diff --git a/pkg/compiler/lib/src/kernel/loader.dart b/pkg/compiler/lib/src/kernel/loader.dart
index 7fd39d4..37531a5 100644
--- a/pkg/compiler/lib/src/kernel/loader.dart
+++ b/pkg/compiler/lib/src/kernel/loader.dart
@@ -61,7 +61,8 @@
String targetName =
_options.compileForServer ? "dart2js_server" : "dart2js";
- // We defer selecting the platform until we've resolved the NNBD mode.
+ // We defer selecting the platform until we've resolved the null safety
+ // mode.
String getPlatformFilename() {
String platform = targetName;
if (!_options.useLegacySubtyping) {
diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart
index 194c2b1..e81dda1 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -838,7 +838,7 @@
_behavior.typesReturned.add(type.withoutNullability);
// Breakdown nullable type into TypeWithoutNullability|Null.
- // Pre-nnbd Declared types are nullable, so we also add null in that case.
+ // Unsound declared types are nullable, so we also add null in that case.
// TODO(41960): Remove check for legacy subtyping. This was added as a
// temporary workaround to unblock the null-safe unfork. At this time some
// native APIs are typed unsoundly because they don't consider browser
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index b83f7ee..3c5ee61 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -708,7 +708,7 @@
if (benchmarkingExperiment) {
// Set flags implied by '--benchmarking-x'.
- // TODO(sra): Use this for some NNBD variant.
+ // TODO(sra): Use this for some null safety variant.
useContentSecurityPolicy = true;
features.forceCanary();
}
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index ef0a3fa..886f1f0 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -3517,10 +3517,10 @@
/// Check for receiver or argument type when lowering operation to a primitive,
/// e.g. lowering `+` to [HAdd].
///
-/// After NNBD, `a + b` will require `a` and `b` are non-nullable and these
-/// checks will become explicit in the source (e.g. `a! + b!`). At that time,
-/// this check should be removed. If needed, the `!` check can be optimized
-/// give the same signals to the JavaScript VM.
+/// With sound null safety, `a + b` will require `a` and `b` to be non-nullable
+/// and these checks will become explicit in the source (e.g. `a! + b!`). At
+/// that time, this check should be removed. If needed, the `!` check can be
+/// optimized to give the same signals to the JavaScript VM.
class HPrimitiveCheck extends HCheck {
// Values for [kind].
static const int ARGUMENT_TYPE_CHECK = 1;
@@ -3590,8 +3590,8 @@
}
/// A check that the input to a condition (if, ?:, while, etc) is non-null. The
-/// front-end generates 'as bool' checks, but until the transition to NNBD is
-/// complete, this allows `null` to be passed to the condition.
+/// front-end generates 'as bool' checks, but until the transition to null
+/// safety is complete, this allows `null` to be passed to the condition.
///
// TODO(sra): Once NNDB is far enough along that the front-end can generate `as
// bool!` checks and the backend checks them correctly, this instruction will
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index bf83ffc..8877f33 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1926,8 +1926,8 @@
@override
HInstruction visitAsCheck(HAsCheck node) {
// TODO(fishythefish): Correctly constant fold `null as T` (also in
- // [visitAsCheckSimple]) when running with strong NNBD. We might get this
- // for free if nullability is precisely propagated to the typemasks.
+ // [visitAsCheckSimple]) when running with sound null safety. We might get
+ // this for free if nullability is precisely propagated to the typemasks.
HInstruction typeInput = node.typeInput;
if (typeInput is HLoadType) {
diff --git a/pkg/compiler/test/closure/data/test_type_class.dart b/pkg/compiler/test/closure/data/test_type_class.dart
index 2d090d6..eff36b1 100644
--- a/pkg/compiler/test/closure/data/test_type_class.dart
+++ b/pkg/compiler/test/closure/data/test_type_class.dart
@@ -33,7 +33,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// Implicit as-cast is only required in spec:nnbd-off mode.
+/// Implicit as-cast is only required in spec mode.
////////////////////////////////////////////////////////////////////////////////
/*member: Class3.:hasThis*/
diff --git a/pkg/compiler/test/closure/data/test_type_method.dart b/pkg/compiler/test/closure/data/test_type_method.dart
index 495ac1b..ee02292 100644
--- a/pkg/compiler/test/closure/data/test_type_method.dart
+++ b/pkg/compiler/test/closure/data/test_type_method.dart
@@ -27,7 +27,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// Implicit as-cast is only required in spec:nnbd-off mode.
+/// Implicit as-cast is only required in spec mode.
////////////////////////////////////////////////////////////////////////////////
/*member: method3:*/
diff --git a/pkg/compiler/test/closure/data/type_annotations_class.dart b/pkg/compiler/test/closure/data/type_annotations_class.dart
index 6c0d99e..f7557f7 100644
--- a/pkg/compiler/test/closure/data/type_annotations_class.dart
+++ b/pkg/compiler/test/closure/data/type_annotations_class.dart
@@ -43,7 +43,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// A local function parameter type is only captured in spec:nnbd-off mode.
+/// A local function parameter type is only captured in spec mode.
////////////////////////////////////////////////////////////////////////////////
/*member: Class2.:hasThis*/
@@ -58,7 +58,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// A local function return type is only captured in spec:nnbd-off mode.
+/// A local function return type is only captured in spec mode.
////////////////////////////////////////////////////////////////////////////////
/*member: Class3.:hasThis*/
diff --git a/pkg/compiler/test/closure/data/type_annotations_method.dart b/pkg/compiler/test/closure/data/type_annotations_method.dart
index 4da1fae..1468024 100644
--- a/pkg/compiler/test/closure/data/type_annotations_method.dart
+++ b/pkg/compiler/test/closure/data/type_annotations_method.dart
@@ -19,7 +19,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// A local function parameter type is captured in spec:nnbd-off mode.
+/// A local function parameter type is captured in spec mode.
////////////////////////////////////////////////////////////////////////////////
method2<T>() {
@@ -29,7 +29,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-/// A local function return type is captured in spec:nnbd-off mode.
+/// A local function return type is captured in spec mode.
////////////////////////////////////////////////////////////////////////////////
method3<T>(dynamic o) {
diff --git a/pkg/compiler/test/codegen/new_rti_is_test.dart b/pkg/compiler/test/codegen/new_rti_is_test.dart
index 1ce65e9..b6d2b53 100644
--- a/pkg/compiler/test/codegen/new_rti_is_test.dart
+++ b/pkg/compiler/test/codegen/new_rti_is_test.dart
@@ -11,7 +11,7 @@
import '../helpers/compiler_helper.dart';
// 'N' tests all have a nullable input so should not reduce is-test.
-// TODO(NNBD): Add tests with non-nullable input types.
+// TODO(sra): Add tests with non-nullable input types.
const TEST1N = r"""
foo(int a) {
diff --git a/pkg/compiler/test/inference/data/list_tracer_typed_data_length.dart b/pkg/compiler/test/inference/data/list_tracer_typed_data_length.dart
index a08ef1a..f47e3ca 100644
--- a/pkg/compiler/test/inference/data/list_tracer_typed_data_length.dart
+++ b/pkg/compiler/test/inference/data/list_tracer_typed_data_length.dart
@@ -6,8 +6,8 @@
import 'dart:typed_data';
-// TODO(johnniwinther): Fix inference for spec:nnbd-off mode. List elements should not
-// be [empty].
+// TODO(johnniwinther): Fix inference for spec mode. List elements should not be
+// [empty].
/*member: myList:Container([null|exact=NativeFloat32List], element: [subclass=JSNumber], length: 42)*/
var myList = new Float32List(42);
diff --git a/pkg/compiler/test/kernel/goldens_test.dart b/pkg/compiler/test/kernel/goldens_test.dart
index a945729..dcef219 100644
--- a/pkg/compiler/test/kernel/goldens_test.dart
+++ b/pkg/compiler/test/kernel/goldens_test.dart
@@ -14,9 +14,9 @@
final String testRootDir = Platform.script.resolve('.').toFilePath();
runTestCase(
- Uri source, List<String> experimentalFlags, bool enableNullSafety) async {
+ Uri source, List<String> experimentalFlags, bool soundNullSafety) async {
final target =
- TestingDart2jsTarget(TargetFlags(enableNullSafety: enableNullSafety));
+ TestingDart2jsTarget(TargetFlags(enableNullSafety: soundNullSafety));
Component component = await compileTestCaseToKernelProgram(source,
target: target, experimentalFlags: experimentalFlags);
@@ -33,13 +33,11 @@
in testCasesDir.listSync(recursive: true, followLinks: false)) {
final path = entry.path;
if (path.endsWith('.dart')) {
- final bool enableNullSafety = path.endsWith('_nnbd_strong.dart');
- final bool enableNNBD = enableNullSafety || path.endsWith('_nnbd.dart');
- final List<String> experimentalFlags = [
- if (enableNNBD) 'non-nullable',
- ];
- test(path,
- () => runTestCase(entry.uri, experimentalFlags, enableNullSafety));
+ final bool unsoundNullSafety = path.endsWith('_unsound.dart');
+ test(
+ path,
+ () => runTestCase(
+ entry.uri, const ['non-nullable'], !unsoundNullSafety));
}
}
}, timeout: Timeout.none);