[VM/Libraries] Fix all errors reported by CFE when the option

performNnbdChecks is turned on.

Bug:40424
Change-Id: I97a283c4a2d54f570def04d938baa9a4ced08667
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137250
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
asiva 2020-03-02 23:03:51 +00:00 committed by commit-bot@chromium.org
parent e211bd28c1
commit 75de086f1d
19 changed files with 99 additions and 85 deletions

View file

@ -6,21 +6,16 @@ ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/i
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '>>': int.>> (int Function(int)), JSNumber.>> (num Function(num)). ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '>>': int.>> (int Function(int)), JSNumber.>> (num Function(num)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '\|': int.\| (int Function(int)), JSNumber.\| (num Function(num)). ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '\|': int.\| (int Function(int)), JSNumber.\| (num Function(num)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '^': int.^ (int Function(int)), JSNumber.^ (num Function(num)). ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '^': int.^ (int Function(int)), JSNumber.^ (num Function(num)).
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1003|10|5|Non-nullable instance field 'value' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1004|10|5|Non-nullable instance field 'value' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1029|8|6|Non-nullable instance field 'secure' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1030|8|6|Non-nullable instance field 'secure' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1035|8|8|Non-nullable instance field 'httpOnly' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1036|8|8|Non-nullable instance field 'httpOnly' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1491|12|11|Non-nullable instance field 'idleTimeout' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1493|12|11|Non-nullable instance field 'idleTimeout' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1541|8|14|Non-nullable instance field 'autoUncompress' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1543|8|14|Non-nullable instance field 'autoUncompress' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|171|8|12|Non-nullable instance field 'autoCompress' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|172|8|12|Non-nullable instance field 'autoCompress' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|990|10|4|Non-nullable instance field 'name' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|991|10|4|Non-nullable instance field 'name' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/io/io.dart|5589|12|8|Non-nullable instance field 'encoding' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/io/io.dart|5589|12|8|Non-nullable instance field 'encoding' must be initialized.
ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1654|28|1|The operator '&' isn't defined for the type 'JSInt'. ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1654|28|1|The operator '&' isn't defined for the type 'JSInt'.
ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1656|27|1|The operator '&' isn't defined for the type 'JSInt'. ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1656|27|1|The operator '&' isn't defined for the type 'JSInt'.
ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1659|17|1|The operator '&' isn't defined for the type 'JSInt'. ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1659|17|1|The operator '&' isn't defined for the type 'JSInt'.
ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1664|18|1|The operator '&' isn't defined for the type 'JSInt'. ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1664|18|1|The operator '&' isn't defined for the type 'JSInt'.
ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1664|44|1|The operator '&' isn't defined for the type 'JSInt'. ERROR|STATIC_TYPE_WARNING|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|1664|44|1|The operator '&' isn't defined for the type 'JSInt'.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|1476|39|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|8384|60|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/developer/developer.dart|315|25|23|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/io/io.dart|9188|16|1|The left operand can't be null, so the right operand is never executed.

View file

@ -15,16 +15,11 @@ ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runti
ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|221|8|37|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|221|8|37|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type.
ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|224|8|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|224|8|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type.
ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|228|6|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MIGHT_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|228|6|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1003|10|5|Non-nullable instance field 'value' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1004|10|5|Non-nullable instance field 'value' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1029|8|6|Non-nullable instance field 'secure' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1030|8|6|Non-nullable instance field 'secure' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1035|8|8|Non-nullable instance field 'httpOnly' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1036|8|8|Non-nullable instance field 'httpOnly' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1491|12|11|Non-nullable instance field 'idleTimeout' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1493|12|11|Non-nullable instance field 'idleTimeout' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1541|8|14|Non-nullable instance field 'autoUncompress' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|1543|8|14|Non-nullable instance field 'autoUncompress' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|171|8|12|Non-nullable instance field 'autoCompress' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|172|8|12|Non-nullable instance field 'autoCompress' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|990|10|4|Non-nullable instance field 'name' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/_http/http.dart|991|10|4|Non-nullable instance field 'name' must be initialized.
ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/io/io.dart|5589|12|8|Non-nullable instance field 'encoding' must be initialized. ERROR|COMPILE_TIME_ERROR|NOT_INITIALIZED_NON_NULLABLE_INSTANCE_FIELD|lib/io/io.dart|5589|12|8|Non-nullable instance field 'encoding' must be initialized.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|1476|39|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|8384|60|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/developer/developer.dart|332|25|23|The left operand can't be null, so the right operand is never executed.
WARNING|STATIC_WARNING|DEAD_NULL_AWARE_EXPRESSION|lib/io/io.dart|9188|16|1|The left operand can't be null, so the right operand is never executed.

View file

@ -16,7 +16,8 @@ import 'dart:collection'
UnmodifiableMapView; UnmodifiableMapView;
import 'dart:convert'; import 'dart:convert';
import 'dart:developer' hide log; import 'dart:developer' hide log;
import 'dart:_internal' show Since, HttpStatus; import 'dart:_internal'
show Since, valueOfNonNullableParamWithDefault, HttpStatus;
import 'dart:math'; import 'dart:math';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
@ -1473,7 +1474,8 @@ abstract class HttpClient {
/// ///
/// Default is `false`. /// Default is `false`.
static set enableTimelineLogging(bool value) { static set enableTimelineLogging(bool value) {
_enableTimelineLogging = value ?? false; _enableTimelineLogging =
valueOfNonNullableParamWithDefault<bool>(value, false);
} }
/// Current state of HTTP request logging from all [HttpClient]s to the /// Current state of HTTP request logging from all [HttpClient]s to the

View file

@ -883,7 +883,9 @@ class _HttpParser extends Stream<_HttpIncoming> {
bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED; bool get upgrade => _connectionUpgrade && _state == _State.UPGRADED;
bool get persistentConnection => _persistentConnection; bool get persistentConnection => _persistentConnection;
void set isHead(bool value) => _noMessageBody = value ?? false; void set isHead(bool value) {
_noMessageBody = valueOfNonNullableParamWithDefault<bool>(value, false);
}
_HttpDetachedIncoming detachIncoming() { _HttpDetachedIncoming detachIncoming() {
// Simulate detached by marking as upgraded. // Simulate detached by marking as upgraded.

View file

@ -407,7 +407,7 @@ abstract class WebSocket
"explicitly to WebSocket.fromUpgradedSocket."); "explicitly to WebSocket.fromUpgradedSocket.");
} }
return new _WebSocketImpl._fromSocket( return new _WebSocketImpl._fromSocket(
socket, protocol, compression, serverSide ?? false); socket, protocol, compression, serverSide);
} }
/** /**

View file

@ -33,15 +33,15 @@ void _print(arg) {
_getPrintClosure() => _print; _getPrintClosure() => _print;
// The current working directory when the embedder was launched. // The current working directory when the embedder was launched.
Uri _workingDirectory; late Uri _workingDirectory;
// The URI that the root script was loaded from. Remembered so that // The URI that the root script was loaded from. Remembered so that
// package imports can be resolved relative to it. The root script is the basis // package imports can be resolved relative to it. The root script is the basis
// for the root library in the VM. // for the root library in the VM.
Uri _rootScript; Uri? _rootScript;
// packagesConfig specified for the isolate. // packagesConfig specified for the isolate.
Uri _packagesConfigUri; Uri? _packagesConfigUri;
// Packages are either resolved looking up in a map or resolved from within a // Packages are either resolved looking up in a map or resolved from within a
// package root. // package root.
@ -50,11 +50,11 @@ bool get _packagesReady => (_packageMap != null) || (_packageError != null);
// Error string set if there was an error resolving package configuration. // Error string set if there was an error resolving package configuration.
// For example not finding a .packages file or packages/ directory, malformed // For example not finding a .packages file or packages/ directory, malformed
// .packages file or any other related error. // .packages file or any other related error.
String _packageError = null; String? _packageError = null;
// The map describing how certain package names are mapped to Uris. // The map describing how certain package names are mapped to Uris.
Uri _packageConfig = null; Uri? _packageConfig = null;
Map<String, Uri> _packageMap = null; Map<String, Uri>? _packageMap = null;
// Special handling for Windows paths so that they are compatible with URI // Special handling for Windows paths so that they are compatible with URI
// handling. // handling.
@ -128,11 +128,12 @@ Uri _resolvePackageUri(Uri uri) {
_log('Resolving package with uri path: ${uri.path}'); _log('Resolving package with uri path: ${uri.path}');
} }
var resolvedUri; var resolvedUri;
if (_packageError != null) { final error = _packageError;
if (error != null) {
if (_traceLoading) { if (_traceLoading) {
_log("Resolving package with pending resolution error: $_packageError"); _log("Resolving package with pending resolution error: $error");
} }
throw _packageError; throw error;
} else { } else {
if (packageNameEnd < 0) { if (packageNameEnd < 0) {
// Package URIs must have a path after the package name, even if it's // Package URIs must have a path after the package name, even if it's
@ -141,7 +142,7 @@ Uri _resolvePackageUri(Uri uri) {
"'package:${uri.path}/', not 'package:${uri.path}'"; "'package:${uri.path}/', not 'package:${uri.path}'";
} }
var packageName = uri.path.substring(0, packageNameEnd); var packageName = uri.path.substring(0, packageNameEnd);
var mapping = _packageMap[packageName]; final mapping = _packageMap![packageName];
if (_traceLoading) { if (_traceLoading) {
_log("Mapped '$packageName' package to '$mapping'"); _log("Mapped '$packageName' package to '$mapping'");
} }
@ -162,14 +163,14 @@ Uri _resolvePackageUri(Uri uri) {
return resolvedUri; return resolvedUri;
} }
void _requestPackagesMap(Uri packageConfig) { void _requestPackagesMap(Uri? packageConfig) {
var msg = null; var msg = null;
if (packageConfig != null) { if (packageConfig != null) {
// Explicitly specified .packages path. // Explicitly specified .packages path.
msg = _handlePackagesRequest(_traceLoading, -2, packageConfig); msg = _handlePackagesRequest(_traceLoading, -2, packageConfig);
} else { } else {
// Search for .packages starting at the root script. // Search for .packages starting at the root script.
msg = _handlePackagesRequest(_traceLoading, -1, _rootScript); msg = _handlePackagesRequest(_traceLoading, -1, _rootScript!);
} }
if (_traceLoading) { if (_traceLoading) {
_log("Requested packages map for '$_rootScript'."); _log("Requested packages map for '$_rootScript'.");
@ -186,10 +187,11 @@ void _requestPackagesMap(Uri packageConfig) {
assert(msg.length >= 2); assert(msg.length >= 2);
assert(msg[1] == null); assert(msg[1] == null);
_packageConfig = Uri.parse(msg[0]); _packageConfig = Uri.parse(msg[0]);
_packageMap = new Map<String, Uri>(); final pmap = new Map<String, Uri>();
_packageMap = pmap;
for (var i = 2; i < msg.length; i += 2) { for (var i = 2; i < msg.length; i += 2) {
// TODO(iposva): Complain about duplicate entries. // TODO(iposva): Complain about duplicate entries.
_packageMap[msg[i]] = Uri.parse(msg[i + 1]); pmap[msg[i]] = Uri.parse(msg[i + 1]);
} }
if (_traceLoading) { if (_traceLoading) {
_log("Setup package map: $_packageMap"); _log("Setup package map: $_packageMap");
@ -591,9 +593,6 @@ String _setPackagesMap(String packagesParam) {
if (_traceLoading) { if (_traceLoading) {
_log("Resolving packages map: $packagesParam"); _log("Resolving packages map: $packagesParam");
} }
if (_workingDirectory == null) {
throw 'No current working directory set.';
}
var packagesName = _sanitizeWindowsPath(packagesParam); var packagesName = _sanitizeWindowsPath(packagesParam);
var packagesUri = Uri.parse(packagesName); var packagesUri = Uri.parse(packagesName);
if (packagesUri.scheme == '') { if (packagesUri.scheme == '') {
@ -616,9 +615,6 @@ String _resolveScriptUri(String scriptName) {
if (_traceLoading) { if (_traceLoading) {
_log("Resolving script: $scriptName"); _log("Resolving script: $scriptName");
} }
if (_workingDirectory == null) {
throw 'No current working directory set.';
}
scriptName = _sanitizeWindowsPath(scriptName); scriptName = _sanitizeWindowsPath(scriptName);
var scriptUri = Uri.parse(scriptName); var scriptUri = Uri.parse(scriptName);
@ -657,7 +653,7 @@ Future<Uri> _getPackageConfigFuture() {
return Future.value(_packageConfig); return Future.value(_packageConfig);
} }
Future<Uri> _resolvePackageUriFuture(Uri packageUri) { Future<Uri?> _resolvePackageUriFuture(Uri packageUri) {
if (_traceLoading) { if (_traceLoading) {
_log("Request for package Uri resolution from user code: $packageUri"); _log("Request for package Uri resolution from user code: $packageUri");
} }
@ -671,7 +667,7 @@ Future<Uri> _resolvePackageUriFuture(Uri packageUri) {
if (!_packagesReady) { if (!_packagesReady) {
_requestPackagesMap(_packagesConfigUri); _requestPackagesMap(_packagesConfigUri);
} }
Uri resolvedUri; Uri? resolvedUri;
try { try {
resolvedUri = _resolvePackageUri(packageUri); resolvedUri = _resolvePackageUri(packageUri);
} catch (e, s) { } catch (e, s) {

View file

@ -45,7 +45,7 @@ Future<Server>? serverFuture;
Server _lazyServerBoot() { Server _lazyServerBoot() {
var localServer = server; var localServer = server;
if (localServer != null) { if (localServer != null) {
return server; return localServer;
} }
// Lazily create service. // Lazily create service.
final service = VMService(); final service = VMService();

View file

@ -383,11 +383,11 @@ class Server {
client.onRequest(message); // exception free, no need to try catch client.onRequest(message); // exception free, no need to try catch
} }
Future<void> _dumpServiceInfoToFile() async { Future<void> _dumpServiceInfoToFile(String serviceInfoFilenameLocal) async {
final serviceInfo = <String, dynamic>{ final serviceInfo = <String, dynamic>{
'uri': serverAddress.toString(), 'uri': serverAddress.toString(),
}; };
final file = File.fromUri(Uri.parse(_serviceInfoFilename)); final file = File.fromUri(Uri.parse(serviceInfoFilenameLocal));
return file.writeAsString(json.encode(serviceInfo)); return file.writeAsString(json.encode(serviceInfo));
} }
@ -456,7 +456,7 @@ class Server {
final serviceInfoFilenameLocal = _serviceInfoFilename; final serviceInfoFilenameLocal = _serviceInfoFilename;
if (serviceInfoFilenameLocal != null && if (serviceInfoFilenameLocal != null &&
serviceInfoFilenameLocal.isNotEmpty) { serviceInfoFilenameLocal.isNotEmpty) {
await _dumpServiceInfoToFile(); await _dumpServiceInfoToFile(serviceInfoFilenameLocal);
} }
// Server is up and running. // Server is up and running.
_notifyServerState(serverAddress.toString()); _notifyServerState(serverAddress.toString());

View file

@ -18,20 +18,20 @@ import "dart:isolate" show SendPort;
// part "timeline.dart" // part "timeline.dart"
@patch @patch
bool debugger({bool when: true, String message}) native "Developer_debugger"; bool debugger({bool when: true, String? message}) native "Developer_debugger";
@patch @patch
Object inspect(Object object) native "Developer_inspect"; Object inspect(Object object) native "Developer_inspect";
@patch @patch
void log(String message, void log(String message,
{DateTime time, {DateTime? time,
int sequenceNumber, int? sequenceNumber,
int level: 0, int level: 0,
String name: '', String name: '',
Zone zone, Zone? zone,
Object error, Object? error,
StackTrace stackTrace}) { StackTrace? stackTrace}) {
if (message is! String) { if (message is! String) {
throw new ArgumentError.value(message, "message", "Must be a String"); throw new ArgumentError.value(message, "message", "Must be a String");
} }
@ -51,7 +51,7 @@ void log(String message,
int _nextSequenceNumber = 0; int _nextSequenceNumber = 0;
_log(String message, int timestamp, int sequenceNumber, int level, String name, _log(String message, int timestamp, int sequenceNumber, int level, String name,
Zone zone, Object error, StackTrace stackTrace) native "Developer_log"; Zone? zone, Object? error, StackTrace? stackTrace) native "Developer_log";
@patch @patch
void _postEvent(String eventKind, String eventData) void _postEvent(String eventKind, String eventData)

View file

@ -29,7 +29,7 @@ int sizeOf<T extends NativeType>() {
// This is not super fast, but it is faster than a runtime entry. // This is not super fast, but it is faster than a runtime entry.
// Hot loops with elementAt().load() do not use this sizeOf, elementAt is // Hot loops with elementAt().load() do not use this sizeOf, elementAt is
// optimized per NativeType statically to prevent use of sizeOf at runtime. // optimized per NativeType statically to prevent use of sizeOf at runtime.
final int knownSize = _knownSizes[T]; final int? knownSize = _knownSizes[T];
if (knownSize != null) return knownSize; if (knownSize != null) return knownSize;
if (T == IntPtr) return _intPtrSize; if (T == IntPtr) return _intPtrSize;
if (T == Pointer) return _intPtrSize; if (T == Pointer) return _intPtrSize;
@ -84,7 +84,7 @@ class Pointer<T extends NativeType> {
@patch @patch
static Pointer<NativeFunction<T>> fromFunction<T extends Function>( static Pointer<NativeFunction<T>> fromFunction<T extends Function>(
@DartRepresentationOf("T") Function f, @DartRepresentationOf("T") Function f,
[Object exceptionalReturn]) { [Object? exceptionalReturn]) {
throw UnsupportedError( throw UnsupportedError(
"Pointer.fromFunction cannot be called dynamically."); "Pointer.fromFunction cannot be called dynamically.");
} }

View file

@ -333,7 +333,7 @@ class Isolate {
} }
@patch @patch
static Future<Uri> resolvePackageUri(Uri packageUri) { static Future<Uri?> resolvePackageUri(Uri packageUri) {
var hook = VMLibraryHooks.resolvePackageUriFuture; var hook = VMLibraryHooks.resolvePackageUriFuture;
if (hook == null) { if (hook == null) {
throw new UnsupportedError("Isolate.resolvePackageUri"); throw new UnsupportedError("Isolate.resolvePackageUri");

View file

@ -424,7 +424,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror {
return _qualifiedName = _computeQualifiedName(owner, simpleName); return _qualifiedName = _computeQualifiedName(owner, simpleName);
} }
DeclarationMirror get owner { DeclarationMirror? get owner {
var o = _owner; var o = _owner;
if (o != null) return o; if (o != null) return o;
@ -927,7 +927,7 @@ class _TypedefMirror extends _DeclarationMirror
bool get isTopLevel => true; bool get isTopLevel => true;
DeclarationMirror? _owner; DeclarationMirror? _owner;
DeclarationMirror get owner { DeclarationMirror? get owner {
var o = _owner; var o = _owner;
if (o != null) return o; if (o != null) return o;
var uri = _ClassMirror._libraryUri(_reflectee); var uri = _ClassMirror._libraryUri(_reflectee);

View file

@ -378,10 +378,11 @@ mixin _IntListMixin implements List<int> {
} }
void fillRange(int start, int end, [int? fillValue]) { void fillRange(int start, int end, [int? fillValue]) {
if (fillValue == null && start < end) { RangeError.checkValidRange(start, end, this.length);
if (start == end) return;
if (fillValue == null) {
throw ArgumentError.notNull("fillValue"); throw ArgumentError.notNull("fillValue");
} }
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) { for (var i = start; i < end; ++i) {
this[i] = fillValue; this[i] = fillValue;
} }
@ -736,10 +737,11 @@ mixin _DoubleListMixin implements List<double> {
void fillRange(int start, int end, [double? fillValue]) { void fillRange(int start, int end, [double? fillValue]) {
// TODO(eernst): Could use zero as default and not throw; issue . // TODO(eernst): Could use zero as default and not throw; issue .
if (fillValue == null && start < end) { RangeError.checkValidRange(start, end, this.length);
if (start == end) return;
if (fillValue == null) {
throw ArgumentError.notNull("fillValue"); throw ArgumentError.notNull("fillValue");
} }
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) { for (var i = start; i < end; ++i) {
this[i] = fillValue; this[i] = fillValue;
} }
@ -1174,10 +1176,11 @@ abstract class _Float32x4ListMixin implements List<Float32x4> {
} }
void fillRange(int start, int end, [Float32x4? fillValue]) { void fillRange(int start, int end, [Float32x4? fillValue]) {
if (fillValue == null && start < end) { RangeError.checkValidRange(start, end, this.length);
if (start == end) return;
if (fillValue == null) {
throw ArgumentError.notNull("fillValue"); throw ArgumentError.notNull("fillValue");
} }
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) { for (var i = start; i < end; ++i) {
this[i] = fillValue; this[i] = fillValue;
} }
@ -1532,10 +1535,11 @@ abstract class _Int32x4ListMixin implements List<Int32x4> {
} }
void fillRange(int start, int end, [Int32x4? fillValue]) { void fillRange(int start, int end, [Int32x4? fillValue]) {
if (fillValue == null && start < end) { RangeError.checkValidRange(start, end, this.length);
if (start == end) return;
if (fillValue == null) {
throw ArgumentError.notNull("fillValue"); throw ArgumentError.notNull("fillValue");
} }
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) { for (var i = start; i < end; ++i) {
this[i] = fillValue; this[i] = fillValue;
} }
@ -1891,10 +1895,11 @@ abstract class _Float64x2ListMixin implements List<Float64x2> {
} }
void fillRange(int start, int end, [Float64x2? fillValue]) { void fillRange(int start, int end, [Float64x2? fillValue]) {
if (fillValue == null && start < end) { RangeError.checkValidRange(start, end, this.length);
if (start == end) return;
if (fillValue == null) {
throw ArgumentError.notNull("fillValue"); throw ArgumentError.notNull("fillValue");
} }
RangeError.checkValidRange(start, end, this.length);
for (var i = start; i < end; ++i) { for (var i = start; i < end; ++i) {
this[i] = fillValue; this[i] = fillValue;
} }

View file

@ -105,11 +105,12 @@ class _NativeWasmImports extends NativeFieldWrapperClass1
} }
class _NativeWasmMemory extends NativeFieldWrapperClass1 implements WasmMemory { class _NativeWasmMemory extends NativeFieldWrapperClass1 implements WasmMemory {
int _pages; late int _pages;
Uint8List _buffer; late Uint8List _buffer;
_NativeWasmMemory(int initialPages, int? maxPages) : _pages = initialPages { _NativeWasmMemory(int initialPages, int? maxPages) {
_buffer = _init(initialPages, maxPages); _buffer = _init(initialPages, maxPages);
_pages = initialPages;
} }
_NativeWasmMemory.fromInstance(_NativeWasmInstance inst) { _NativeWasmMemory.fromInstance(_NativeWasmInstance inst) {

View file

@ -57,10 +57,11 @@ void Function(int)? _waitForEventClosure;
class _WaitForUtils { class _WaitForUtils {
static void waitForEvent({Duration? timeout}) { static void waitForEvent({Duration? timeout}) {
if (_waitForEventClosure == null) { final closure = _waitForEventClosure;
if (closure == null) {
throw new UnsupportedError("waitFor is not supported by this embedder"); throw new UnsupportedError("waitFor is not supported by this embedder");
} }
_waitForEventClosure(timeout == null ? 0 : max(1, timeout.inMilliseconds)); closure(timeout == null ? 0 : max(1, timeout.inMilliseconds));
} }
} }
@ -145,7 +146,7 @@ T waitFor<T>(Future<T> future, {Duration? timeout}) {
Timer.run(() {}); // Ensure that previous calls to waitFor are woken up. Timer.run(() {}); // Ensure that previous calls to waitFor are woken up.
if (error != null) { if (error != null) {
throw new AsyncError(error, stacktrace); throw new AsyncError(error!, stacktrace);
} }
return result; return result;

View file

@ -63,7 +63,7 @@ class Gauge extends Metric {
} }
Gauge(String name, String description, this.min, this.max) Gauge(String name, String description, this.min, this.max)
: _value = min ?? double.negativeInfinity, : _value = min,
super(name, description) { super(name, description) {
// TODO: When NNBD is complete, delete the following two lines. // TODO: When NNBD is complete, delete the following two lines.
ArgumentError.checkNotNull(min, 'min'); ArgumentError.checkNotNull(min, 'min');

View file

@ -54,7 +54,7 @@ class Pointer<T extends NativeType> extends NativeType {
/// [dynamic]. /// [dynamic].
external static Pointer<NativeFunction<T>> fromFunction<T extends Function>( external static Pointer<NativeFunction<T>> fromFunction<T extends Function>(
@DartRepresentationOf("T") Function f, @DartRepresentationOf("T") Function f,
[Object exceptionalReturn]); [Object? exceptionalReturn]);
/// Access to the raw pointer value. /// Access to the raw pointer value.
/// On 32-bit systems, the upper 32-bits of the result are 0. /// On 32-bit systems, the upper 32-bits of the result are 0.

View file

@ -229,6 +229,24 @@ class NotNullableError<T> extends Error implements TypeError {
"Null is not a valid value for the parameter '$_name' of type '$T'"; "Null is not a valid value for the parameter '$_name' of type '$T'";
} }
/// A function that returns the value or default value (if invoked with `null`
/// value) for non-nullable function parameters in Null safety enabled code.
///
/// Because Dart does not have full null safety
/// until all legacy code has been removed from a program,
/// a non-nullable parameter can still end up with a `null` value.
/// This function can be used to get a default value for a parameter
/// when a `null` value is passed in for a non-nullable parameter.
///
/// TODO(40810) - Remove uses of this function when Dart has full null safety.
T valueOfNonNullableParamWithDefault<T extends Object>(T value, T defaultVal) {
if ((value as dynamic) == null) {
return defaultVal;
} else {
return value;
}
}
/** /**
* HTTP status codes. Exported in dart:io and dart:html. * HTTP status codes. Exported in dart:io and dart:html.
*/ */

View file

@ -709,7 +709,6 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
return 0; return 0;
} }
if (_status != connectedStatus) return 0; if (_status != connectedStatus) return 0;
offset ??= 0;
bytes ??= data.length - offset; bytes ??= data.length - offset;
int written = int written =