Revert "[ddc] Verify null safety modes of modules agree"

This reverts commit fda897a423.

Reason for revert: Breaks all the flutter web tests here:
https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/flutter-engine-linux-web_tests/1089/overview

This indicates we still have a misconfiguration in flutter web dev 
builds where artifacts with different null safety modes are being 
mixed.

Original change's description:
> [ddc] Verify null safety modes of modules agree
>
> Checks that the null safety mode of every module loaded matches the mode
> of the SDK.
>
> Change-Id: I50543d10fbea22a61bd7f12d51d6e9c8f8286890
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173120
> Commit-Queue: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>

TBR=sigmund@google.com,nshahan@google.com,markzipan@google.com

Change-Id: I0d09efde53f268b353cb842286b11bb3f375e754
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173440
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2020-11-21 17:42:25 +00:00 committed by commit-bot@chromium.org
parent 4fe5b79c07
commit a9f3c66bd8
3 changed files with 2 additions and 43 deletions

View file

@ -345,7 +345,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Visit each library and emit its code.
//
// NOTE: classes are not necessarily emitted in this order.
// NOTE: clases are not necessarily emitted in this order.
// Order will be changed as needed so the resulting code can execute.
// This is done by forward declaring items.
libraries.forEach(_emitLibrary);
@ -375,31 +375,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Declare imports and extension symbols
emitImportsAndExtensionSymbols(items);
// Insert a check that runs when loading this module to verify that the null
// safety mode it was compiled in matches the mode used when compiling the
// dart sdk module.
//
// This serves as a sanity check at runtime that we don't have an
// infrastructure issue that loaded js files compiled with different modes
// into the same application.
js_ast.LiteralBool soundNullSafety;
switch (component.mode) {
case NonNullableByDefaultCompiledMode.Strong:
soundNullSafety = js_ast.LiteralBool(true);
break;
case NonNullableByDefaultCompiledMode.Weak:
soundNullSafety = js_ast.LiteralBool(false);
break;
default:
throw FormatException('Unsupported Null Safety mode ${component.mode}, '
'in ${component?.location?.file}.');
}
if (!isBuildingSdk) {
items.add(runtimeCall('_checkModuleNullSafetyMode(#)', [soundNullSafety])
.toStatement());
}
// Discharge the type table cache variables and
// hoisted definitions.
items.addAll(_typeTable.discharge());

View file

@ -65,8 +65,7 @@ class SetupCompilerOptions {
..omitPlatform = true
..sdkSummary = sdkRoot.resolve(
soundNullSafety ? sdkSoundSummaryPath : sdkUnsoundSummaryPath)
..environmentDefines = const {}
..nnbdMode = soundNullSafety ? NnbdMode.Strong : NnbdMode.Weak;
..environmentDefines = const {};
return options;
}

View file

@ -24,21 +24,6 @@ assertFailed(String? message,
throw AssertionErrorImpl(message, fileUri, line, column, conditionSource);
}
/// Throws if [isModuleSound] does not match the null safety mode of this SDK.
///
/// The call to this method is inserted into every module at compile time when
/// the compile time null safety mode for the module is known.
void _checkModuleNullSafetyMode(@notNull bool isModuleSound) {
if (isModuleSound != compileTimeFlag('soundNullSafety')) {
var sdkMode = compileTimeFlag('soundNullSafety') ? 'sound' : 'unsound';
var moduleMode = isModuleSound ? 'sound' : 'unsound';
throw AssertionError('The null safety mode of the Dart SDK module '
'($sdkMode) does not match the null safety mode of this module '
'($moduleMode).');
}
}
final _nullFailedSet = JS('!', 'new Set()');
String _nullFailedMessage(variableName) =>