Unverified Commit 39bc68b6 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] dont use autodetect enum for web (#70189)

parent f877d9fd
...@@ -124,7 +124,7 @@ class WebAssetServer implements AssetReader { ...@@ -124,7 +124,7 @@ class WebAssetServer implements AssetReader {
this.internetAddress, this.internetAddress,
this._modules, this._modules,
this._digests, this._digests,
this._buildInfo, this._nullSafetyMode,
) : basePath = _parseBasePathFromIndexHtml(globals.fs.currentDirectory ) : basePath = _parseBasePathFromIndexHtml(globals.fs.currentDirectory
.childDirectory('web') .childDirectory('web')
.childFile('index.html')); .childFile('index.html'));
...@@ -169,7 +169,8 @@ class WebAssetServer implements AssetReader { ...@@ -169,7 +169,8 @@ class WebAssetServer implements AssetReader {
BuildInfo buildInfo, BuildInfo buildInfo,
bool enableDwds, bool enableDwds,
Uri entrypoint, Uri entrypoint,
ExpressionCompiler expressionCompiler, { ExpressionCompiler expressionCompiler,
NullSafetyMode nullSafetyMode, {
bool testMode = false, bool testMode = false,
DwdsLauncher dwdsLauncher = Dwds.start, DwdsLauncher dwdsLauncher = Dwds.start,
}) async { }) async {
...@@ -209,7 +210,7 @@ class WebAssetServer implements AssetReader { ...@@ -209,7 +210,7 @@ class WebAssetServer implements AssetReader {
address, address,
modules, modules,
digests, digests,
buildInfo, nullSafetyMode,
); );
if (testMode) { if (testMode) {
return server; return server;
...@@ -293,7 +294,7 @@ class WebAssetServer implements AssetReader { ...@@ -293,7 +294,7 @@ class WebAssetServer implements AssetReader {
return server; return server;
} }
final BuildInfo _buildInfo; final NullSafetyMode _nullSafetyMode;
final HttpServer _httpServer; final HttpServer _httpServer;
// If holding these in memory is too much overhead, this can be switched to a // If holding these in memory is too much overhead, this can be switched to a
// RandomAccessFile and read on demand. // RandomAccessFile and read on demand.
...@@ -672,12 +673,12 @@ class WebAssetServer implements AssetReader { ...@@ -672,12 +673,12 @@ class WebAssetServer implements AssetReader {
File get _resolveDartSdkJsFile => File get _resolveDartSdkJsFile =>
globals.fs.file(globals.artifacts.getArtifactPath( globals.fs.file(globals.artifacts.getArtifactPath(
_dartSdkJsArtifactMap[webRenderer][_buildInfo.nullSafetyMode] _dartSdkJsArtifactMap[webRenderer][_nullSafetyMode]
)); ));
File get _resolveDartSdkJsMapFile => File get _resolveDartSdkJsMapFile =>
globals.fs.file(globals.artifacts.getArtifactPath( globals.fs.file(globals.artifacts.getArtifactPath(
_dartSdkJsMapArtifactMap[webRenderer][_buildInfo.nullSafetyMode] _dartSdkJsMapArtifactMap[webRenderer][_nullSafetyMode]
)); ));
@override @override
...@@ -735,6 +736,7 @@ class WebDevFS implements DevFS { ...@@ -735,6 +736,7 @@ class WebDevFS implements DevFS {
@required this.expressionCompiler, @required this.expressionCompiler,
@required this.chromiumLauncher, @required this.chromiumLauncher,
@required this.nullAssertions, @required this.nullAssertions,
@required this.nullSafetyMode,
this.testMode = false, this.testMode = false,
}) : _port = port; }) : _port = port;
...@@ -751,6 +753,7 @@ class WebDevFS implements DevFS { ...@@ -751,6 +753,7 @@ class WebDevFS implements DevFS {
final ChromiumLauncher chromiumLauncher; final ChromiumLauncher chromiumLauncher;
final bool nullAssertions; final bool nullAssertions;
final int _port; final int _port;
final NullSafetyMode nullSafetyMode;
WebAssetServer webAssetServer; WebAssetServer webAssetServer;
...@@ -823,6 +826,7 @@ class WebDevFS implements DevFS { ...@@ -823,6 +826,7 @@ class WebDevFS implements DevFS {
enableDwds, enableDwds,
entrypoint, entrypoint,
expressionCompiler, expressionCompiler,
nullSafetyMode,
testMode: testMode, testMode: testMode,
); );
final int selectedPort = webAssetServer.selectedPort; final int selectedPort = webAssetServer.selectedPort;
......
...@@ -508,6 +508,7 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -508,6 +508,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
expressionCompiler: expressionCompiler, expressionCompiler: expressionCompiler,
chromiumLauncher: _chromiumLauncher, chromiumLauncher: _chromiumLauncher,
nullAssertions: debuggingOptions.nullAssertions, nullAssertions: debuggingOptions.nullAssertions,
nullSafetyMode: device.nullSafetyMode,
); );
final Uri url = await device.devFS.create(); final Uri url = await device.devFS.create();
if (debuggingOptions.buildInfo.isDebug) { if (debuggingOptions.buildInfo.isDebug) {
......
...@@ -48,6 +48,7 @@ class FlutterDevice { ...@@ -48,6 +48,7 @@ class FlutterDevice {
TargetPlatform targetPlatform, TargetPlatform targetPlatform,
ResidentCompiler generator, ResidentCompiler generator,
this.userIdentifier, this.userIdentifier,
this.nullSafetyMode = NullSafetyMode.autodetect,
}) : assert(buildInfo.trackWidgetCreation != null), }) : assert(buildInfo.trackWidgetCreation != null),
generator = generator ?? ResidentCompiler( generator = generator ?? ResidentCompiler(
globals.artifacts.getArtifactPath( globals.artifacts.getArtifactPath(
...@@ -83,6 +84,7 @@ class FlutterDevice { ...@@ -83,6 +84,7 @@ class FlutterDevice {
String userIdentifier, String userIdentifier,
}) async { }) async {
ResidentCompiler generator; ResidentCompiler generator;
NullSafetyMode nullSafetyMode = buildInfo.nullSafetyMode;
final TargetPlatform targetPlatform = await device.targetPlatform; final TargetPlatform targetPlatform = await device.targetPlatform;
if (device.platformType == PlatformType.fuchsia) { if (device.platformType == PlatformType.fuchsia) {
targetModel = TargetModel.flutterRunner; targetModel = TargetModel.flutterRunner;
...@@ -118,12 +120,14 @@ class FlutterDevice { ...@@ -118,12 +120,14 @@ class FlutterDevice {
...?buildInfo.extraFrontEndOptions, ...?buildInfo.extraFrontEndOptions,
'--sound-null-safety', '--sound-null-safety',
]; ];
nullSafetyMode = NullSafetyMode.sound;
} else { } else {
platformDillArtifact = Artifact.webPlatformKernelDill; platformDillArtifact = Artifact.webPlatformKernelDill;
extraFrontEndOptions = <String>[ extraFrontEndOptions = <String>[
...?buildInfo.extraFrontEndOptions, ...?buildInfo.extraFrontEndOptions,
'--no-sound-null-safety', '--no-sound-null-safety',
]; ];
nullSafetyMode = NullSafetyMode.unsound;
} }
} }
...@@ -198,6 +202,7 @@ class FlutterDevice { ...@@ -198,6 +202,7 @@ class FlutterDevice {
generator: generator, generator: generator,
buildInfo: buildInfo, buildInfo: buildInfo,
userIdentifier: userIdentifier, userIdentifier: userIdentifier,
nullSafetyMode: nullSafetyMode,
); );
} }
...@@ -205,6 +210,7 @@ class FlutterDevice { ...@@ -205,6 +210,7 @@ class FlutterDevice {
final ResidentCompiler generator; final ResidentCompiler generator;
final BuildInfo buildInfo; final BuildInfo buildInfo;
final String userIdentifier; final String userIdentifier;
final NullSafetyMode nullSafetyMode;
DevFSWriter devFSWriter; DevFSWriter devFSWriter;
Stream<Uri> observatoryUris; Stream<Uri> observatoryUris;
......
...@@ -629,6 +629,7 @@ void main() { ...@@ -629,6 +629,7 @@ void main() {
testMode: true, testMode: true,
expressionCompiler: null, expressionCompiler: null,
chromiumLauncher: null, chromiumLauncher: null,
nullSafetyMode: NullSafetyMode.unsound,
); );
webDevFS.requireJS.createSync(recursive: true); webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true); webDevFS.stackTraceMapper.createSync(recursive: true);
...@@ -745,6 +746,7 @@ void main() { ...@@ -745,6 +746,7 @@ void main() {
testMode: true, testMode: true,
expressionCompiler: null, expressionCompiler: null,
chromiumLauncher: null, chromiumLauncher: null,
nullSafetyMode: NullSafetyMode.autodetect,
); );
webDevFS.requireJS.createSync(recursive: true); webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true); webDevFS.stackTraceMapper.createSync(recursive: true);
...@@ -853,6 +855,7 @@ void main() { ...@@ -853,6 +855,7 @@ void main() {
expressionCompiler: null, expressionCompiler: null,
chromiumLauncher: null, chromiumLauncher: null,
nullAssertions: true, nullAssertions: true,
nullSafetyMode: NullSafetyMode.sound,
); );
webDevFS.requireJS.createSync(recursive: true); webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true); webDevFS.stackTraceMapper.createSync(recursive: true);
...@@ -903,6 +906,7 @@ void main() { ...@@ -903,6 +906,7 @@ void main() {
testMode: true, testMode: true,
expressionCompiler: null, expressionCompiler: null,
chromiumLauncher: null, chromiumLauncher: null,
nullSafetyMode: NullSafetyMode.sound,
); );
webDevFS.requireJS.createSync(recursive: true); webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true); webDevFS.stackTraceMapper.createSync(recursive: true);
...@@ -954,6 +958,7 @@ void main() { ...@@ -954,6 +958,7 @@ void main() {
testMode: true, testMode: true,
expressionCompiler: null, expressionCompiler: null,
chromiumLauncher: null, chromiumLauncher: null,
nullSafetyMode: NullSafetyMode.sound,
); );
webDevFS.requireJS.createSync(recursive: true); webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true); webDevFS.stackTraceMapper.createSync(recursive: true);
...@@ -981,6 +986,7 @@ void main() { ...@@ -981,6 +986,7 @@ void main() {
false, false,
Uri.base, Uri.base,
null, null,
null,
testMode: true); testMode: true);
expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null); expect(webAssetServer.defaultResponseHeaders['x-frame-options'], null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment