diff --git a/sdk/lib/_internal/vm/bin/builtin.dart b/sdk/lib/_internal/vm/bin/builtin.dart index 53cccb3bbf8..a960eec5f9f 100644 --- a/sdk/lib/_internal/vm/bin/builtin.dart +++ b/sdk/lib/_internal/vm/bin/builtin.dart @@ -189,7 +189,7 @@ void _requestPackagesMap(Uri? packageConfig) { assert(msg.length >= 2); assert(msg[1] == null); _packageConfig = Uri.parse(msg[0]); - final pmap = new Map(); + final pmap = Map(); _packageMap = pmap; for (var i = 2; i < msg.length; i += 2) { // TODO(iposva): Complain about duplicate entries. @@ -335,7 +335,7 @@ _findPackagesConfiguration(bool traceLoading, Uri base) { // of // - .packages (preferred) // - .dart_tool/package_config.json - var currentDir = new File.fromUri(base).parent; + var currentDir = File.fromUri(base).parent; while (true) { final dirUri = currentDir.uri; @@ -497,7 +497,7 @@ void _Init( _setupHooks(); // _workingDirectory must be set first. - _workingDirectory = new Uri.directory(workingDirectory); + _workingDirectory = Uri.directory(workingDirectory); // setup _rootScript. if (rootScript != null) { @@ -521,7 +521,7 @@ void _setWorkingDirectory(String cwd) { if (_traceLoading) { _log('Setting working directory: $cwd'); } - _workingDirectory = new Uri.directory(cwd); + _workingDirectory = Uri.directory(cwd); if (_traceLoading) { _log('Working directory URI: $_workingDirectory'); } diff --git a/sdk/lib/_internal/vm/bin/directory_patch.dart b/sdk/lib/_internal/vm/bin/directory_patch.dart index 58de8eb0d54..f2bae3dd97a 100644 --- a/sdk/lib/_internal/vm/bin/directory_patch.dart +++ b/sdk/lib/_internal/vm/bin/directory_patch.dart @@ -53,7 +53,7 @@ class _Directory { class _AsyncDirectoryListerOps { @patch factory _AsyncDirectoryListerOps(int pointer) => - new _AsyncDirectoryListerOpsImpl(pointer); + _AsyncDirectoryListerOpsImpl(pointer); } base class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1 @@ -61,7 +61,7 @@ base class _AsyncDirectoryListerOpsImpl extends NativeFieldWrapperClass1 _AsyncDirectoryListerOpsImpl._(); factory _AsyncDirectoryListerOpsImpl(int pointer) => - new _AsyncDirectoryListerOpsImpl._().._setPointer(pointer); + _AsyncDirectoryListerOpsImpl._().._setPointer(pointer); @pragma("vm:external-name", "Directory_SetAsyncDirectoryListerPointer") external void _setPointer(int pointer); @@ -79,13 +79,13 @@ Uri _uriBaseClosure() { } var result = _Directory._current(_Namespace._namespace); if (result is OSError) { - throw new FileSystemException._fromOSError( + throw FileSystemException._fromOSError( result, "Getting current working directory failed", "", ); } - return new Uri.directory(result as String); + return Uri.directory(result as String); } @pragma("vm:entry-point", "call") diff --git a/sdk/lib/_internal/vm/bin/file_patch.dart b/sdk/lib/_internal/vm/bin/file_patch.dart index 88892097055..7ac836eb2a0 100644 --- a/sdk/lib/_internal/vm/bin/file_patch.dart +++ b/sdk/lib/_internal/vm/bin/file_patch.dart @@ -91,7 +91,7 @@ class _File { class _RandomAccessFileOps { @patch factory _RandomAccessFileOps(int pointer) => - new _RandomAccessFileOpsImpl(pointer); + _RandomAccessFileOpsImpl(pointer); } @pragma("vm:entry-point") @@ -100,7 +100,7 @@ base class _RandomAccessFileOpsImpl extends NativeFieldWrapperClass1 _RandomAccessFileOpsImpl._(); factory _RandomAccessFileOpsImpl(int pointer) => - new _RandomAccessFileOpsImpl._().._setPointer(pointer); + _RandomAccessFileOpsImpl._().._setPointer(pointer); @pragma("vm:external-name", "File_SetPointer") external void _setPointer(int pointer); @@ -156,7 +156,7 @@ abstract class _FileSystemWatcher { _WatcherPath? _watcherPath; final StreamController _broadcastController = - new StreamController.broadcast(); + StreamController.broadcast(); /// Subscription on the stream returned by [_watchPath]. /// @@ -171,26 +171,22 @@ abstract class _FileSystemWatcher { bool recursive, ) { if (Platform.isLinux || Platform.isAndroid) { - return new _InotifyFileSystemWatcher(path, events, recursive)._stream; + return _InotifyFileSystemWatcher(path, events, recursive)._stream; } if (Platform.isWindows) { - return new _Win32FileSystemWatcher(path, events, recursive)._stream; + return _Win32FileSystemWatcher(path, events, recursive)._stream; } if (Platform.isMacOS) { - return new _FSEventStreamFileSystemWatcher( - path, - events, - recursive, - )._stream; + return _FSEventStreamFileSystemWatcher(path, events, recursive)._stream; } - throw new FileSystemException( + throw FileSystemException( "File system watching is not supported on this platform", ); } _FileSystemWatcher._(this._path, this._events, this._recursive) { if (!isSupported) { - throw new FileSystemException( + throw FileSystemException( "File system watching is not supported on this platform", _path, ); @@ -236,7 +232,7 @@ abstract class _FileSystemWatcher { return; } if (!_idMap.containsKey(pathId)) { - _idMap[pathId] = new _WatcherPath(pathId, _path, _events); + _idMap[pathId] = _WatcherPath(pathId, _path, _events); } _watcherPath = _idMap[pathId]; _watcherPath!.count++; @@ -324,9 +320,9 @@ abstract class _FileSystemWatcher { void rewriteMove(event, isDir) { if (event[3]) { - add(event[4], new FileSystemCreateEvent(getPath(event), isDir)); + add(event[4], FileSystemCreateEvent(getPath(event), isDir)); } else { - add(event[4], new FileSystemDeleteEvent(getPath(event), false)); + add(event[4], FileSystemDeleteEvent(getPath(event), false)); } } @@ -344,13 +340,13 @@ abstract class _FileSystemWatcher { bool isDir = getIsDir(event); var path = getPath(event); if ((event[0] & FileSystemEvent.create) != 0) { - add(event[4], new FileSystemCreateEvent(path, isDir)); + add(event[4], FileSystemCreateEvent(path, isDir)); } if ((event[0] & FileSystemEvent.modify) != 0) { - add(event[4], new FileSystemModifyEvent(path, isDir, true)); + add(event[4], FileSystemModifyEvent(path, isDir, true)); } if ((event[0] & FileSystemEvent._modifyAttributes) != 0) { - add(event[4], new FileSystemModifyEvent(path, isDir, false)); + add(event[4], FileSystemModifyEvent(path, isDir, false)); } if ((event[0] & FileSystemEvent.move) != 0) { int link = event[1]; @@ -359,7 +355,7 @@ abstract class _FileSystemWatcher { if (pair[pathId].containsKey(link)) { add( event[4], - new FileSystemMoveEvent( + FileSystemMoveEvent( getPath(pair[pathId][link]), isDir, path, @@ -374,10 +370,10 @@ abstract class _FileSystemWatcher { } } if ((event[0] & FileSystemEvent.delete) != 0) { - add(event[4], new FileSystemDeleteEvent(path, false)); + add(event[4], FileSystemDeleteEvent(path, false)); } if ((event[0] & FileSystemEvent._deleteSelf) != 0) { - add(event[4], new FileSystemDeleteEvent(path, false)); + add(event[4], FileSystemDeleteEvent(path, false)); // Signal done event. stops.add([event[4], null]); } @@ -479,7 +475,7 @@ class _InotifyFileSystemWatcher extends _FileSystemWatcher { Stream _pathWatched() { var pathId = _watcherPath!.pathId; if (!_idMap.containsKey(pathId)) { - _idMap[pathId] = new StreamController.broadcast(); + _idMap[pathId] = StreamController.broadcast(); } return _idMap[pathId]!.stream; } @@ -501,7 +497,7 @@ class _Win32FileSystemWatcher extends _FileSystemWatcher { Stream _pathWatched() { var pathId = _watcherPath!.pathId; - _controller = new StreamController(); + _controller = StreamController(); _subscription = _FileSystemWatcher._listenOnSocket( pathId, 0, @@ -533,7 +529,7 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher { Stream _pathWatched() { var pathId = _watcherPath!.pathId; var socketId = _FileSystemWatcher._getSocketId(0, pathId); - _controller = new StreamController(); + _controller = StreamController(); _subscription = _FileSystemWatcher._listenOnSocket( socketId, 0, @@ -556,5 +552,5 @@ class _FSEventStreamFileSystemWatcher extends _FileSystemWatcher { @pragma("vm:entry-point", "call") Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { - return new Uint8List.view(source.buffer, offsetInBytes, length); + return Uint8List.view(source.buffer, offsetInBytes, length); } diff --git a/sdk/lib/_internal/vm/bin/filter_patch.dart b/sdk/lib/_internal/vm/bin/filter_patch.dart index 6df875ba363..c8222735514 100644 --- a/sdk/lib/_internal/vm/bin/filter_patch.dart +++ b/sdk/lib/_internal/vm/bin/filter_patch.dart @@ -66,7 +66,7 @@ class RawZLibFilter { int strategy, List? dictionary, bool raw, - ) => new _ZLibDeflateFilter( + ) => _ZLibDeflateFilter( gzip, level, windowBits, @@ -81,5 +81,5 @@ class RawZLibFilter { int windowBits, List? dictionary, bool raw, - ) => new _ZLibInflateFilter(gzip, windowBits, dictionary, raw); + ) => _ZLibInflateFilter(gzip, windowBits, dictionary, raw); } diff --git a/sdk/lib/_internal/vm/bin/io_service_patch.dart b/sdk/lib/_internal/vm/bin/io_service_patch.dart index ff4b2c0e08d..587d163e016 100644 --- a/sdk/lib/_internal/vm/bin/io_service_patch.dart +++ b/sdk/lib/_internal/vm/bin/io_service_patch.dart @@ -17,7 +17,7 @@ class _IOService { assert(data.length == 2); _forwardResponse(data[0] as int, data[1]); }, 'IO Service'); - static HashMap _messageMap = new HashMap(); + static HashMap _messageMap = HashMap(); static int _id = 0; @patch @@ -26,7 +26,7 @@ class _IOService { do { id = _getNextId(); } while (_messageMap.containsKey(id)); - final Completer completer = new Completer(); + final Completer completer = Completer(); try { if (_messageMap.isEmpty) { // This is the first outgoing request after being in an idle state, diff --git a/sdk/lib/_internal/vm/bin/namespace_patch.dart b/sdk/lib/_internal/vm/bin/namespace_patch.dart index cf8b43aaf6f..7ce21b41609 100644 --- a/sdk/lib/_internal/vm/bin/namespace_patch.dart +++ b/sdk/lib/_internal/vm/bin/namespace_patch.dart @@ -20,14 +20,14 @@ base class _NamespaceImpl extends NativeFieldWrapperClass1 // embedder with the platform-specific namespace information. static _NamespaceImpl? _cachedNamespace = null; static void _setupNamespace(var namespace) { - _cachedNamespace = _create(new _NamespaceImpl._(), namespace); + _cachedNamespace = _create(_NamespaceImpl._(), namespace); } static _NamespaceImpl get _namespace { if (_cachedNamespace == null) { // The embedder has not supplied a namespace before one is needed, so // instead use a safe-ish default value. - _cachedNamespace = _create(new _NamespaceImpl._(), _getDefault()); + _cachedNamespace = _create(_NamespaceImpl._(), _getDefault()); } return _cachedNamespace!; } diff --git a/sdk/lib/_internal/vm/bin/platform_patch.dart b/sdk/lib/_internal/vm/bin/platform_patch.dart index 6da84b008fa..1b6b43ea61a 100644 --- a/sdk/lib/_internal/vm/bin/platform_patch.dart +++ b/sdk/lib/_internal/vm/bin/platform_patch.dart @@ -60,7 +60,7 @@ class _Platform { path.startsWith('file:')) { return Uri.parse(path); } else { - return Uri.base.resolveUri(new Uri.file(path)); + return Uri.base.resolveUri(Uri.file(path)); } }); } diff --git a/sdk/lib/_internal/vm/bin/process_patch.dart b/sdk/lib/_internal/vm/bin/process_patch.dart index a43770f6844..6de77a572f5 100644 --- a/sdk/lib/_internal/vm/bin/process_patch.dart +++ b/sdk/lib/_internal/vm/bin/process_patch.dart @@ -30,7 +30,7 @@ class Process { bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal, }) { - _ProcessImpl process = new _ProcessImpl( + _ProcessImpl process = _ProcessImpl( executable, arguments, workingDirectory, @@ -96,12 +96,12 @@ class Process { } } -List<_SignalController?> _signalControllers = new List.filled(32, null); +List<_SignalController?> _signalControllers = List.filled(32, null); class _SignalController { final ProcessSignal signal; - final _controller = new StreamController.broadcast(); + final _controller = StreamController.broadcast(); var _id; _SignalController(this.signal) { @@ -115,13 +115,11 @@ class _SignalController { void _listen() { var id = _setSignalHandler(signal.signalNumber); if (id is! int) { - _controller.addError( - new SignalException("Failed to listen for $signal", id), - ); + _controller.addError(SignalException("Failed to listen for $signal", id)); return; } _id = id; - var socket = new _RawSocket(new _NativeSocket.watchSignal(id)); + var socket = _RawSocket(_NativeSocket.watchSignal(id)); socket.listen((event) { if (event == RawSocketEvent.read) { var bytes = socket.read()!; @@ -176,16 +174,14 @@ class _ProcessUtils { (signal != ProcessSignal.sigusr1 && signal != ProcessSignal.sigusr2 && signal != ProcessSignal.sigwinch))) { - throw new SignalException( - "Listening for signal $signal is not supported", - ); + throw SignalException("Listening for signal $signal is not supported"); } return _watchSignalInternal(signal); } static Stream _watchSignalInternal(ProcessSignal signal) { if (_signalControllers[signal.signalNumber] == null) { - _signalControllers[signal.signalNumber] = new _SignalController(signal); + _signalControllers[signal.signalNumber] = _SignalController(signal); } return _signalControllers[signal.signalNumber]!.stream; } @@ -299,14 +295,14 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { if (_modeHasStdio(_mode)) { // stdin going to process. - _stdin = new _StdSink(new _Socket._writePipe().._owner = this); + _stdin = _StdSink(_Socket._writePipe().._owner = this); // stdout coming from process. - _stdout = new _StdStream(new _Socket._readPipe().._owner = this); + _stdout = _StdStream(_Socket._readPipe().._owner = this); // stderr coming from process. - _stderr = new _StdStream(new _Socket._readPipe().._owner = this); + _stderr = _StdStream(_Socket._readPipe().._owner = this); } if (_modeIsAttached(_mode)) { - _exitHandler = new _Socket._readPipe(); + _exitHandler = _Socket._readPipe(); } } @@ -346,7 +342,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { shellArguments.add(arg); } } else { - var commandLine = new StringBuffer(); + var commandLine = StringBuffer(); executable = executable.replaceAll("'", "'\"'\"'"); commandLine.write("'$executable'"); shellArguments.add("-c"); @@ -373,7 +369,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { // Replace any number of '\' followed by '"' with // twice as many '\' followed by '\"'. var backslash = '\\'.codeUnitAt(0); - var sb = new StringBuffer(); + var sb = StringBuffer(); var nextPos = 0; var quotePos = argument.indexOf('"', nextPos); while (quotePos != -1) { @@ -396,7 +392,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { // Add '"' at the beginning and end and replace all '\' at // the end with two '\'. - sb = new StringBuffer('"'); + sb = StringBuffer('"'); sb.write(result); nextPos = argument.length - 1; while (argument.codeUnitAt(nextPos) == backslash) { @@ -418,15 +414,15 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { } Future _start() { - var completer = new Completer(); + var completer = Completer(); var stackTrace = StackTrace.current; if (_modeIsAttached(_mode)) { - _exitCode = new Completer(); + _exitCode = Completer(); } // TODO(ager): Make the actual process starting really async instead of // simulating it with a timer. Timer.run(() { - var status = new _ProcessStartStatus(); + var status = _ProcessStartStatus(); bool success = _startNative( _Namespace._namespace, _path, @@ -442,7 +438,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { ); if (!success) { completer.completeError( - new ProcessException( + ProcessException( _path, _arguments, status._errorMessage!, @@ -454,14 +450,14 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { } _started = true; - final resourceInfo = new _SpawnedProcessResourceInfo(this); + final resourceInfo = _SpawnedProcessResourceInfo(this); // Setup an exit handler to handle internal cleanup and possible // callback when a process terminates. if (_modeIsAttached(_mode)) { int exitDataRead = 0; final int EXIT_DATA_SIZE = 8; - List exitDataBuffer = new List.filled(EXIT_DATA_SIZE, 0); + List exitDataBuffer = List.filled(EXIT_DATA_SIZE, 0); _exitHandler.listen((data) { int exitCode(List ints) { var code = _intFromBytes(ints, 0); @@ -501,8 +497,8 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { Encoding? stdoutEncoding, Encoding? stderrEncoding, ) { - var status = new _ProcessStartStatus(); - _exitCode = new Completer(); + var status = _ProcessStartStatus(); + _exitCode = Completer(); bool success = _startNative( _Namespace._namespace, _path, @@ -517,7 +513,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { status, ); if (!success) { - throw new ProcessException( + throw ProcessException( _path, _arguments, status._errorMessage!, @@ -525,7 +521,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { ); } - final resourceInfo = new _SpawnedProcessResourceInfo(this); + final resourceInfo = _SpawnedProcessResourceInfo(this); var result = _wait( _stdinNativeSocket, @@ -541,7 +537,7 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { resourceInfo.stopped(); - return new ProcessResult( + return ProcessResult( result[0], result[1], getOutput(result[2], stdoutEncoding), @@ -641,14 +637,14 @@ Future _runNonInteractiveProcess( if (encoding == null) { return stream .fold( - new BytesBuilder(), + BytesBuilder(), (builder, data) => builder..add(data), ) .then((builder) => builder.takeBytes()); } else { return stream .transform(encoding.decoder) - .fold(new StringBuffer(), (buf, data) { + .fold(StringBuffer(), (buf, data) { buf.write(data); return buf; }) @@ -660,7 +656,7 @@ Future _runNonInteractiveProcess( Future stderr = foldStream(p.stderr, stderrEncoding); return Future.wait([p.exitCode, stdout, stderr]).then((result) { - return new ProcessResult(pid, result[0], result[1], result[2]); + return ProcessResult(pid, result[0], result[1], result[2]); }); }); } @@ -675,7 +671,7 @@ ProcessResult _runNonInteractiveProcessSync( Encoding? stdoutEncoding, Encoding? stderrEncoding, ) { - var process = new _ProcessImpl( + var process = _ProcessImpl( executable, arguments, workingDirectory, diff --git a/sdk/lib/_internal/vm/bin/secure_socket_patch.dart b/sdk/lib/_internal/vm/bin/secure_socket_patch.dart index 6f69dcf2e54..61d9381bfc8 100644 --- a/sdk/lib/_internal/vm/bin/secure_socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/secure_socket_patch.dart @@ -7,14 +7,13 @@ part of "common_patch.dart"; @patch class SecureSocket { @patch - factory SecureSocket._(RawSecureSocket rawSocket) => - new _SecureSocket(rawSocket); + factory SecureSocket._(RawSecureSocket rawSocket) => _SecureSocket(rawSocket); } @patch class _SecureFilter { @patch - factory _SecureFilter._() => new _SecureFilterImpl._(); + factory _SecureFilter._() => _SecureFilterImpl._(); } @patch @@ -22,7 +21,7 @@ class _SecureFilter { class X509Certificate { @patch @pragma("vm:entry-point") - factory X509Certificate._() => new _X509CertificateImpl._(); + factory X509Certificate._() => _X509CertificateImpl._(); } class _SecureSocket extends _Socket implements SecureSocket { @@ -38,14 +37,14 @@ class _SecureSocket extends _Socket implements SecureSocket { X509Certificate? get peerCertificate { if (_raw == null) { - throw new StateError("peerCertificate called on destroyed SecureSocket"); + throw StateError("peerCertificate called on destroyed SecureSocket"); } return _raw!.peerCertificate; } String? get selectedProtocol { if (_raw == null) { - throw new StateError("selectedProtocol called on destroyed SecureSocket"); + throw StateError("selectedProtocol called on destroyed SecureSocket"); } return _raw!.selectedProtocol; } @@ -74,7 +73,7 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1 _SecureFilterImpl._() { buffers = <_ExternalBuffer>[ for (int i = 0; i < _RawSecureSocket.bufferCount; ++i) - new _ExternalBuffer( + _ExternalBuffer( _RawSecureSocket._isBufferEncrypted(i) ? ENCRYPTED_SIZE : SIZE, ), ]; @@ -158,9 +157,9 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1 } } - void rehandshake() => throw new UnimplementedError(); + void rehandshake() => throw UnimplementedError(); - int processBuffer(int bufferIndex) => throw new UnimplementedError(); + int processBuffer(int bufferIndex) => throw UnimplementedError(); @pragma("vm:external-name", "SecureSocket_GetSelectedProtocol") external String? selectedProtocol(); @@ -203,7 +202,7 @@ base class _SecureFilterImpl extends NativeFieldWrapperClass1 class SecurityContext { @patch factory SecurityContext({bool withTrustedRoots = false}) { - return new _SecurityContext(withTrustedRoots); + return _SecurityContext(withTrustedRoots); } @patch @@ -245,10 +244,10 @@ base class _SecurityContext extends NativeFieldWrapperClass1 @pragma("vm:external-name", "SecurityContext_Allocate") external void _createNativeContext(); - static final SecurityContext defaultContext = new _SecurityContext(true); + static final SecurityContext defaultContext = _SecurityContext(true); void usePrivateKey(String file, {String? password}) { - List bytes = (new File(file)).readAsBytesSync(); + List bytes = (File(file)).readAsBytesSync(); usePrivateKeyBytes(bytes, password: password); } @@ -256,7 +255,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1 external void usePrivateKeyBytes(List keyBytes, {String? password}); void setTrustedCertificates(String file, {String? password}) { - List bytes = (new File(file)).readAsBytesSync(); + List bytes = (File(file)).readAsBytesSync(); setTrustedCertificatesBytes(bytes, password: password); } @@ -267,7 +266,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1 }); void useCertificateChain(String file, {String? password}) { - List bytes = (new File(file)).readAsBytesSync(); + List bytes = (File(file)).readAsBytesSync(); useCertificateChainBytes(bytes, password: password); } @@ -278,7 +277,7 @@ base class _SecurityContext extends NativeFieldWrapperClass1 }); void setClientAuthorities(String file, {String? password}) { - List bytes = (new File(file)).readAsBytesSync(); + List bytes = (File(file)).readAsBytesSync(); setClientAuthoritiesBytes(bytes, password: password); } @@ -334,14 +333,11 @@ base class _X509CertificateImpl extends NativeFieldWrapperClass1 @pragma("vm:external-name", "X509_Issuer") external String get issuer; DateTime get startValidity { - return new DateTime.fromMillisecondsSinceEpoch( - _startValidity(), - isUtc: true, - ); + return DateTime.fromMillisecondsSinceEpoch(_startValidity(), isUtc: true); } DateTime get endValidity { - return new DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true); + return DateTime.fromMillisecondsSinceEpoch(_endValidity(), isUtc: true); } @pragma("vm:external-name", "X509_StartValidity") diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart index a5ed2554982..4ae6fe6b1b9 100644 --- a/sdk/lib/_internal/vm/bin/socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/socket_patch.dart @@ -141,7 +141,7 @@ void _throwOnBadPort(int port) { // TODO(40614): Remove once non-nullability is sound. ArgumentError.checkNotNull(port, "port"); if ((port < 0) || (port > 0xFFFF)) { - throw new ArgumentError("Invalid port $port"); + throw ArgumentError("Invalid port $port"); } } @@ -149,7 +149,7 @@ void _throwOnBadTtl(int ttl) { // TODO(40614): Remove once non-nullability is sound. ArgumentError.checkNotNull(ttl, "ttl"); if (ttl < 1 || ttl > 255) { - throw new ArgumentError('Invalid ttl $ttl'); + throw ArgumentError('Invalid ttl $ttl'); } } @@ -178,7 +178,7 @@ class _InternetAddress implements InternetAddress { String get host => _host ?? address; - Uint8List get rawAddress => new Uint8List.fromList(_in_addr); + Uint8List get rawAddress => Uint8List.fromList(_in_addr); bool get isLoopback { switch (type) { @@ -194,7 +194,7 @@ class _InternetAddress implements InternetAddress { case InternetAddressType.unix: return false; } - throw new UnsupportedError("Unexpected address type $type"); + throw UnsupportedError("Unexpected address type $type"); } bool get isLinkLocal { @@ -210,7 +210,7 @@ class _InternetAddress implements InternetAddress { case InternetAddressType.unix: return false; } - throw new UnsupportedError("Unexpected address type $type"); + throw UnsupportedError("Unexpected address type $type"); } bool get isMulticast { @@ -226,7 +226,7 @@ class _InternetAddress implements InternetAddress { case InternetAddressType.unix: return false; } - throw new UnsupportedError("Unexpected address type $type"); + throw UnsupportedError("Unexpected address type $type"); } Future reverse() { @@ -528,10 +528,8 @@ base class _NativeSocket extends _NativeSocketNativeWrapper static const int normalTokenBatchSize = 8; static const int listeningTokenBatchSize = 2; - static const Duration _retryDuration = const Duration(milliseconds: 250); - static const Duration _retryDurationLoopback = const Duration( - milliseconds: 25, - ); + static const Duration _retryDuration = Duration(milliseconds: 250); + static const Duration _retryDurationLoopback = Duration(milliseconds: 25); // Socket close state bool isClosed = false; @@ -539,7 +537,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper bool isClosedRead = false; bool closedReadEventSent = false; bool isClosedWrite = false; - Completer closeCompleter = new Completer.sync(); + Completer closeCompleter = Completer.sync(); // Handlers and receive port for socket events from the event handler. void Function()? readEventHandler; @@ -633,7 +631,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper throw createError(response, "Failed listing interfaces"); } else { var map = (response as List).skip(1).fold( - new Map(), + Map(), (map, result) { List resultList = result as List; var type = InternetAddressType._from(resultList[0] as int); @@ -647,7 +645,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper ); if (!includeLinkLocal && address.isLinkLocal) return map; if (!includeLoopback && address.isLoopback) return map; - map.putIfAbsent(name, () => new _NetworkInterface(name, index)); + map.putIfAbsent(name, () => _NetworkInterface(name, index)); (map[name] as _NetworkInterface).addresses.add(address); return map; }, @@ -665,7 +663,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper if (!checkLinkLocalAddress(host)) { // The only well defined usage is link-local address. Checks Section 4 of https://tools.ietf.org/html/rfc6874. // If it is not a valid link-local address and contains escape character, throw an exception. - throw new FormatException( + throw FormatException( '${host} is not a valid link-local address but contains %. Scope id should be used as part of link-local address.', host, index, @@ -811,7 +809,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper } source = sourceAddress; } else if (sourceAddress is String) { - source = new _InternetAddress.fromString(sourceAddress); + source = _InternetAddress.fromString(sourceAddress); } else { throw ArgumentError.value( sourceAddress, @@ -823,7 +821,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper final stackTrace = StackTrace.current; - return new Future.value(host).then>((host) { + return Future.value(host).then>((host) { if (host is String) { // Attempt to interpret the host as a numeric address // (e.g. "127.0.0.1"). This will prevent [InternetAddress.lookup] from @@ -868,7 +866,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper StackTrace callerStackTrace, ) { // Completer for result. - final result = new Completer<_NativeSocket>(); + final result = Completer<_NativeSocket>(); // Error, set if an error occurs. // Keeps first error if multiple errors occur. var error = null; @@ -1012,7 +1010,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper return; } final address = pendingLookedUp.removeFirst(); - final socket = new _NativeSocket.normal(address); + final socket = _NativeSocket.normal(address); // Will contain values of various types representing the result // of trying to create a connection. // A value of `true` means success, everything else means failure. @@ -1049,7 +1047,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper // succeed or fail later. final duration = address.isLoopback ? _retryDurationLoopback : _retryDuration; - timer = new Timer(duration, connectNext); + timer = Timer(duration, connectNext); connecting.add(socket); // Setup handlers for receiving the first write event which // indicate that the socket is fully connected. @@ -1136,7 +1134,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper ); connectNext(); - return new ConnectionTask<_NativeSocket>._(result.future, onCancel); + return ConnectionTask<_NativeSocket>._(result.future, onCancel); } static Future<_NativeSocket> connect( @@ -1196,7 +1194,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper } final address = await _resolveHost(host); - var socket = new _NativeSocket.listen(address); + var socket = _NativeSocket.listen(address); var result; if (address.type == InternetAddressType.unix) { var path = address.address; @@ -1220,7 +1218,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper ); } if (result is OSError) { - throw new SocketException( + throw SocketException( "Failed to create server socket", osError: result, address: address, @@ -1244,7 +1242,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper final address = await _resolveHost(host); - var socket = new _NativeSocket.datagram(address); + var socket = _NativeSocket.datagram(address); var result = socket.nativeCreateBindDatagram( address._in_addr, port, @@ -1253,7 +1251,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper ttl, ); if (result is OSError) { - throw new SocketException( + throw SocketException( "Failed to create datagram socket", osError: result, address: address, @@ -1295,8 +1293,8 @@ base class _NativeSocket extends _NativeSocketNativeWrapper bool get isTcp => (typeFlags & typeTcpSocket) != 0; bool get isUdp => (typeFlags & typeUdpSocket) != 0; - String get _serviceTypePath => throw new UnimplementedError(); - String get _serviceTypeName => throw new UnimplementedError(); + String get _serviceTypePath => throw UnimplementedError(); + String get _serviceTypeName => throw UnimplementedError(); Uint8List? read(int? count) { if (count != null && count <= 0) { @@ -1431,14 +1429,14 @@ base class _NativeSocket extends _NativeSocketNativeWrapper offset = _fixOffset(offset); if (bytes == null) { if (offset > buffer.length) { - throw new RangeError.value(offset); + throw RangeError.value(offset); } bytes = buffer.length - offset; } - if (offset < 0) throw new RangeError.value(offset); - if (bytes < 0) throw new RangeError.value(bytes); + if (offset < 0) throw RangeError.value(offset); + if (bytes < 0) throw RangeError.value(bytes); if ((offset + bytes) > buffer.length) { - throw new RangeError.value(offset + bytes); + throw RangeError.value(offset + bytes); } if (isClosing || isClosed) return 0; if (bytes == 0) return 0; @@ -1526,14 +1524,14 @@ base class _NativeSocket extends _NativeSocketNativeWrapper int? bytes, List controlMessages, ) { - if (offset < 0) throw new RangeError.value(offset); + if (offset < 0) throw RangeError.value(offset); if (bytes != null) { - if (bytes < 0) throw new RangeError.value(bytes); + if (bytes < 0) throw RangeError.value(bytes); } else { bytes = buffer.length - offset; } if ((offset + bytes) > buffer.length) { - throw new RangeError.value(offset + bytes); + throw RangeError.value(offset + bytes); } if (isClosing || isClosed) return 0; try { @@ -1577,7 +1575,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper connections--; tokens++; returnTokens(listeningTokenBatchSize); - var socket = new _NativeSocket.normal(address); + var socket = _NativeSocket.normal(address); if (nativeAccept(socket) != true) return null; socket.localPort = localPort; return socket; @@ -1606,7 +1604,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper if (isClosing || isClosed) throw const SocketException.closed(); var result = nativeGetRemotePeer(); var addr = result[0] as List; - var type = new InternetAddressType._from(addr[0] as int); + var type = InternetAddressType._from(addr[0] as int); if (type == InternetAddressType.unix) { return _InternetAddress.fromString( addr[1] as String, @@ -1835,7 +1833,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper close(); break; default: - throw new ArgumentError(direction); + throw ArgumentError(direction); } } } @@ -1875,7 +1873,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper void connectToEventHandler() { assert(!isClosed); if (eventPort == null) { - eventPort = new RawReceivePort(multiplex, 'Socket Event Handler'); + eventPort = RawReceivePort(multiplex, 'Socket Event Handler'); } } @@ -1988,7 +1986,7 @@ base class _NativeSocket extends _NativeSocketNativeWrapper } } // No IPv4 address found on the interface. - throw new SocketException( + throw SocketException( "The network interface does not have an address " "of the same family as the multicast address", ); @@ -2152,14 +2150,14 @@ class _RawServerSocket extends Stream bool shared, ) { _throwOnBadPort(port); - if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog"); + if (backlog < 0) throw ArgumentError("Invalid backlog $backlog"); return _NativeSocket.bind( address, port, backlog, v6Only, shared, - ).then((socket) => new _RawServerSocket(socket, v6Only)); + ).then((socket) => _RawServerSocket(socket, v6Only)); } _RawServerSocket(this._socket, this._v6Only); @@ -2171,11 +2169,11 @@ class _RawServerSocket extends Stream bool? cancelOnError, }) { if (_controller != null) { - throw new StateError("Stream was already listened to"); + throw StateError("Stream was already listened to"); } var zone = Zone.current; final controller = - _controller = new StreamController( + _controller = StreamController( sync: true, onListen: _onSubscriptionStateChange, onCancel: _onSubscriptionStateChange, @@ -2255,7 +2253,7 @@ class _RawServerSocket extends Stream class _RawSocket extends Stream implements RawSocket, _RawSocketBase { final _NativeSocket _socket; - final _controller = new StreamController(sync: true); + final _controller = StreamController(sync: true); bool _readEventsEnabled = true; bool _writeEventsEnabled = true; @@ -2345,17 +2343,17 @@ class _RawSocket extends Stream } factory _RawSocket._writePipe() { - var native = new _NativeSocket.pipe(); + var native = _NativeSocket.pipe(); native.isClosedRead = true; native.closedReadEventSent = true; - return new _RawSocket(native); + return _RawSocket(native); } factory _RawSocket._readPipe(int? fd) { - var native = new _NativeSocket.pipe(); + var native = _NativeSocket.pipe(); native.isClosedWrite = true; if (fd != null) _getStdioHandle(native, fd); - var result = new _RawSocket(native); + var result = _RawSocket(native); if (fd != null) { var socketType = _StdIOUtils._nativeSocketType(result._socket); result._isMacOSTerminalInput = @@ -2515,7 +2513,7 @@ class _ServerSocket extends Stream implements ServerSocket { backlog, v6Only, shared, - ).then((socket) => new _ServerSocket(socket)); + ).then((socket) => _ServerSocket(socket)); } _ServerSocket(this._socket); @@ -2527,7 +2525,7 @@ class _ServerSocket extends Stream implements ServerSocket { bool? cancelOnError, }) { return _socket - .map((rawSocket) => new _Socket(rawSocket)) + .map((rawSocket) => _Socket(rawSocket)) .listen( onData, onError: onError, @@ -2564,7 +2562,7 @@ class Socket { sourceAddress: sourceAddress, sourcePort: sourcePort, timeout: timeout, - ).then((socket) => new _Socket(socket)); + ).then((socket) => _Socket(socket)); } @patch @@ -2581,9 +2579,9 @@ class Socket { sourcePort: sourcePort, ).then((rawTask) { Future socket = rawTask.socket.then( - (rawSocket) => new _Socket(rawSocket), + (rawSocket) => _Socket(rawSocket), ); - return new ConnectionTask._(socket, rawTask._onCancel); + return ConnectionTask._(socket, rawTask._onCancel); }); } } @@ -2600,7 +2598,7 @@ class _SocketStreamConsumer implements StreamConsumer> { Future addStream(Stream> stream) { socket._ensureRawSocketSubscription(); - final completer = streamCompleter = new Completer(); + final completer = streamCompleter = Completer(); if (socket._raw != null) { subscription = stream.listen( (data) { @@ -2640,7 +2638,7 @@ class _SocketStreamConsumer implements StreamConsumer> { Future close() { socket._consumerDone(); - return new Future.value(socket); + return Future.value(socket); } bool get _previousWriteHasCompleted { @@ -2710,7 +2708,7 @@ class _SocketStreamConsumer implements StreamConsumer> { class _Socket extends Stream implements Socket { RawSocket? _raw; // Set to null when the raw socket is closed. bool _closed = false; // Set to true when the raw socket is closed. - final _controller = new StreamController(sync: true); + final _controller = StreamController(sync: true); bool _controllerClosed = false; late _SocketStreamConsumer _consumer; late IOSink _sink; @@ -2723,8 +2721,8 @@ class _Socket extends Stream implements Socket { ..onCancel = _onSubscriptionStateChange ..onPause = _onPauseStateChange ..onResume = _onPauseStateChange; - _consumer = new _SocketStreamConsumer(this); - _sink = new IOSink(_consumer); + _consumer = _SocketStreamConsumer(this); + _sink = IOSink(_consumer); // Disable read events until there is a subscription. raw.readEventsEnabled = false; @@ -2734,11 +2732,11 @@ class _Socket extends Stream implements Socket { } factory _Socket._writePipe() { - return new _Socket(new _RawSocket._writePipe()); + return _Socket(_RawSocket._writePipe()); } factory _Socket._readPipe([int? fd]) { - return new _Socket(new _RawSocket._readPipe(fd)); + return _Socket(_RawSocket._readPipe(fd)); } // Note: this code seems a bit suspicious because _raw can be _RawSocket and @@ -2783,7 +2781,7 @@ class _Socket extends Stream implements Socket { /// Throws an [UnsupportedError] because errors cannot be transmitted over a /// [Socket]. void addError(Object error, [StackTrace? stackTrace]) { - throw new UnsupportedError("Cannot send errors on sockets"); + throw UnsupportedError("Cannot send errors on sockets"); } Future addStream(Stream> stream) { @@ -2992,7 +2990,7 @@ class _RawDatagramSocket extends Stream _RawDatagramSocket(this._socket) { var zone = Zone.current; - _controller = new StreamController( + _controller = StreamController( sync: true, onListen: _onSubscriptionStateChange, onCancel: _onSubscriptionStateChange, @@ -3160,7 +3158,7 @@ Datagram _makeDatagram( int port, int type, ) { - return new Datagram( + return Datagram( data, _InternetAddress(InternetAddressType._from(type), address, null, in_addr), port, diff --git a/sdk/lib/_internal/vm/bin/stdio_patch.dart b/sdk/lib/_internal/vm/bin/stdio_patch.dart index 4cc01600009..e9d28a0d67d 100644 --- a/sdk/lib/_internal/vm/bin/stdio_patch.dart +++ b/sdk/lib/_internal/vm/bin/stdio_patch.dart @@ -21,11 +21,11 @@ class _StdIOUtils { case _stdioHandleTypePipe: case _stdioHandleTypeSocket: case _stdioHandleTypeOther: - return new Stdin._(new _Socket._readPipe(fd), fd); + return Stdin._(_Socket._readPipe(fd), fd); case _stdioHandleTypeFile: - return new Stdin._(new _FileStream.forStdin(), fd); + return Stdin._(_FileStream.forStdin(), fd); } - throw new UnsupportedError("Unexpected handle type $type"); + throw UnsupportedError("Unexpected handle type $type"); } @patch @@ -38,7 +38,7 @@ class _StdIOUtils { type, ); } - return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); + return Stdout._(IOSink(_StdConsumer(fd)), fd); } @patch @@ -50,7 +50,7 @@ class _StdIOUtils { static int _nativeSocketType(_NativeSocket nativeSocket) { var result = _getSocketType(nativeSocket); if (result is OSError) { - throw new FileSystemException("Error retrieving socket type", "", result); + throw FileSystemException("Error retrieving socket type", "", result); } return result; } @@ -66,7 +66,7 @@ class Stdin { int readByteSync() { var result = _readByte(_fd); if (result is OSError) { - throw new StdinException("Error reading byte from stdin", result); + throw StdinException("Error reading byte from stdin", result); } return result; } @@ -75,7 +75,7 @@ class Stdin { bool get echoMode { var result = _echoMode(_fd); if (result is OSError) { - throw new StdinException("Error getting terminal echo mode", result); + throw StdinException("Error getting terminal echo mode", result); } return result; } @@ -83,13 +83,11 @@ class Stdin { @patch void set echoMode(bool enabled) { if (!_EmbedderConfig._maySetEchoMode) { - throw new UnsupportedError( - "This embedder disallows setting Stdin.echoMode", - ); + throw UnsupportedError("This embedder disallows setting Stdin.echoMode"); } var result = _setEchoMode(_fd, enabled); if (result is OSError) { - throw new StdinException("Error setting terminal echo mode", result); + throw StdinException("Error setting terminal echo mode", result); } } @@ -97,10 +95,7 @@ class Stdin { bool get echoNewlineMode { var result = _echoNewlineMode(_fd); if (result is OSError) { - throw new StdinException( - "Error getting terminal echo newline mode", - result, - ); + throw StdinException("Error getting terminal echo newline mode", result); } return result; } @@ -108,16 +103,13 @@ class Stdin { @patch void set echoNewlineMode(bool enabled) { if (!_EmbedderConfig._maySetEchoNewlineMode) { - throw new UnsupportedError( + throw UnsupportedError( "This embedder disallows setting Stdin.echoNewlineMode", ); } var result = _setEchoNewlineMode(_fd, enabled); if (result is OSError) { - throw new StdinException( - "Error setting terminal echo newline mode", - result, - ); + throw StdinException("Error setting terminal echo newline mode", result); } } @@ -125,7 +117,7 @@ class Stdin { bool get lineMode { var result = _lineMode(_fd); if (result is OSError) { - throw new StdinException("Error getting terminal line mode", result); + throw StdinException("Error getting terminal line mode", result); } return result; } @@ -133,13 +125,11 @@ class Stdin { @patch void set lineMode(bool enabled) { if (!_EmbedderConfig._maySetLineMode) { - throw new UnsupportedError( - "This embedder disallows setting Stdin.lineMode", - ); + throw UnsupportedError("This embedder disallows setting Stdin.lineMode"); } var result = _setLineMode(_fd, enabled); if (result is OSError) { - throw new StdinException("Error setting terminal line mode", result); + throw StdinException("Error setting terminal line mode", result); } } @@ -147,7 +137,7 @@ class Stdin { bool get supportsAnsiEscapes { var result = _supportsAnsiEscapes(_fd); if (result is OSError) { - throw new StdinException("Error determining ANSI support", result); + throw StdinException("Error determining ANSI support", result); } return result; } @@ -182,7 +172,7 @@ class Stdout { static List _terminalSize(int fd) { var size = _getTerminalSize(fd); if (size is! List) { - throw new StdoutException("Could not get terminal size", size); + throw StdoutException("Could not get terminal size", size); } return size; } @@ -194,7 +184,7 @@ class Stdout { static bool _supportsAnsiEscapes(int fd) { var result = _getAnsiSupported(fd); if (result is! bool) { - throw new StdoutException("Error determining ANSI support", result); + throw StdoutException("Error determining ANSI support", result); } return result; } diff --git a/sdk/lib/_internal/vm/bin/sync_socket_patch.dart b/sdk/lib/_internal/vm/bin/sync_socket_patch.dart index 6e3341dc3ce..42b7dea4e6e 100644 --- a/sdk/lib/_internal/vm/bin/sync_socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/sync_socket_patch.dart @@ -19,7 +19,7 @@ class _RawSynchronousSocket implements RawSynchronousSocket { static RawSynchronousSocket connectSync(host, int port) { _throwOnBadPort(port); - return new _RawSynchronousSocket( + return _RawSynchronousSocket( _NativeSynchronousSocket.connectSync(host, port), ); } @@ -65,7 +65,7 @@ base class _NativeSynchronousSocket static _NativeSynchronousSocket connectSync(host, int port) { if (host == null) { - throw new ArgumentError("Parameter host cannot be null"); + throw ArgumentError("Parameter host cannot be null"); } late List<_InternetAddress> addresses; var error = null; @@ -89,7 +89,7 @@ base class _NativeSynchronousSocket throw error; } var address = it.current; - var socket = new _NativeSynchronousSocket(); + var socket = _NativeSynchronousSocket(); socket.localAddress = address; var result = socket._nativeCreateConnectSync(address._in_addr, port); if (result is OSError) { @@ -178,14 +178,14 @@ base class _NativeSynchronousSocket int? port, ]) { if (error is OSError) { - return new SocketException( + return SocketException( message, osError: error, address: address, port: port, ); } else { - return new SocketException(message, address: address, port: port); + return SocketException(message, address: address, port: port); } } @@ -199,7 +199,7 @@ base class _NativeSynchronousSocket } return <_InternetAddress>[ for (int i = 0; i < response.length; ++i) - new _InternetAddress( + _InternetAddress( InternetAddressType._from(response[i][0]), response[i][1], host, @@ -214,7 +214,7 @@ base class _NativeSynchronousSocket ArgumentError.checkNotNull(start, "start"); _checkAvailable(); if (isClosedRead) { - throw new SocketException("Socket is closed for reading"); + throw SocketException("Socket is closed for reading"); } end = RangeError.checkValidRange(start, end, buffer.length); if (end == start) { @@ -222,7 +222,7 @@ base class _NativeSynchronousSocket } var result = _nativeReadInto(buffer, start, end - start); if (result is OSError) { - throw new SocketException("readIntoSync failed", osError: result); + throw SocketException("readIntoSync failed", osError: result); } return result; } @@ -230,11 +230,11 @@ base class _NativeSynchronousSocket List? readSync(int len) { _checkAvailable(); if (isClosedRead) { - throw new SocketException("Socket is closed for reading"); + throw SocketException("Socket is closed for reading"); } if ((len != null) && (len < 0)) { - throw new ArgumentError("Illegal length $len"); + throw ArgumentError("Illegal length $len"); } if (len == 0) { return null; @@ -261,7 +261,7 @@ base class _NativeSynchronousSocket closeSync(); break; default: - throw new ArgumentError(direction); + throw ArgumentError(direction); } } @@ -295,7 +295,7 @@ base class _NativeSynchronousSocket ArgumentError.checkNotNull(start, "start"); _checkAvailable(); if (isClosedWrite) { - throw new SocketException("Socket is closed for writing"); + throw SocketException("Socket is closed for writing"); } end = RangeError.checkValidRange(start, end, buffer.length); if (end == start) { @@ -312,7 +312,7 @@ base class _NativeSynchronousSocket end - (start - bufferAndStart.start), ); if (result is OSError) { - throw new SocketException("writeFromSync failed", osError: result); + throw SocketException("writeFromSync failed", osError: result); } } diff --git a/sdk/lib/_internal/vm/bin/vmservice_io.dart b/sdk/lib/_internal/vm/bin/vmservice_io.dart index b56a4d1daca..32a38b54fd6 100644 --- a/sdk/lib/_internal/vm/bin/vmservice_io.dart +++ b/sdk/lib/_internal/vm/bin/vmservice_io.dart @@ -13,65 +13,65 @@ part 'resident_compiler_utils.dart'; part 'vmservice_server.dart'; // The TCP ip/port that dds listens on. -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) int _ddsPort = 0; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) String _ddsIP = ''; // The TCP ip/port that the HTTP server listens on. -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) int _port = 0; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) String _ip = ''; // Should the HTTP server auto start? -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _autoStart = false; // Should the HTTP server require an auth code? -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _authCodesDisabled = false; // Should the HTTP server run in devmode? -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _originCheckDisabled = false; // Location of file to output VM service connection info. -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) String? _serviceInfoFilename; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _isWindows = false; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _isFuchsia = false; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) Stream Function(ProcessSignal signal)? _signalWatch; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) StreamSubscription? _signalSubscription; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _serveDevtools = true; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _enableServicePortFallback = false; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _waitForDdsToAdvertiseService = false; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _serveObservatory = false; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) bool _printDtd = false; File? _residentCompilerInfoFile = null; -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) void _populateResidentCompilerInfoFile( /// If either `--resident-compiler-info-file` or `--resident-server-info-file` /// was supplied on the command line, the CLI argument should be forwarded as @@ -270,7 +270,7 @@ void _registerSignalHandler() { ).listen((_) => _toggleWebServer()); } -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) void main() { // Set embedder hooks. VMServiceEmbedderHooks.cleanup = cleanupCallback; diff --git a/sdk/lib/_internal/vm/lib/array.dart b/sdk/lib/_internal/vm/lib/array.dart index 3cf9551caf3..e31e508ccc3 100644 --- a/sdk/lib/_internal/vm/lib/array.dart +++ b/sdk/lib/_internal/vm/lib/array.dart @@ -19,7 +19,7 @@ abstract class _Array extends FixedLengthListBase { @pragma("vm:prefer-inline") _List _slice(int start, int count, bool needsTypeArgument) { if (count <= 64) { - final result = needsTypeArgument ? new _List(count) : new _List(count); + final result = needsTypeArgument ? _List(count) : _List(count); for (int i = 0; i < result.length; i++) { result[i] = this[start + i]; } @@ -44,7 +44,7 @@ abstract class _Array extends FixedLengthListBase { @pragma("vm:prefer-inline") Iterator get iterator { - return new _ArrayIterator(this); + return _ArrayIterator(this); } E get first { @@ -68,12 +68,12 @@ abstract class _Array extends FixedLengthListBase { if (length > 0) { _List result = _slice(0, length, !growable); if (growable) { - return new _GrowableList._withData(result).._setLength(length); + return _GrowableList._withData(result).._setLength(length); } return unsafeCast<_List>(result); } // _GrowableList._withData must not be called with empty list. - return growable ? [] : new _List(0); + return growable ? [] : _List(0); } } @@ -195,10 +195,10 @@ class _List extends _Array { // List interface. void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { if (start < 0 || start > this.length) { - throw new RangeError.range(start, 0, this.length); + throw RangeError.range(start, 0, this.length); } if (end < start || end > this.length) { - throw new RangeError.range(end, start, this.length); + throw RangeError.range(end, start, this.length); } int length = end - start; if (length == 0) return; @@ -224,7 +224,7 @@ class _List extends _Array { void setAll(int index, Iterable iterable) { if (index < 0 || index > this.length) { - throw new RangeError.range(index, 0, this.length, "index"); + throw RangeError.range(index, 0, this.length, "index"); } List iterableAsList; if (identical(this, iterable)) { @@ -241,7 +241,7 @@ class _List extends _Array { } int length = iterableAsList.length; if (index + length > this.length) { - throw new RangeError.range(index + length, 0, this.length); + throw RangeError.range(index + length, 0, this.length); } Lists.copy(iterableAsList, 0, this, index, length); } @@ -251,7 +251,7 @@ class _List extends _Array { final int actualEnd = RangeError.checkValidRange(start, end, listLength); int length = actualEnd - start; if (length == 0) return []; - var result = new _GrowableList._withData(_slice(start, length, false)); + var result = _GrowableList._withData(_slice(start, length, false)); result._setLength(length); return result; } @@ -261,9 +261,7 @@ class _List extends _Array { @pragma("vm:entry-point") class _ImmutableList extends _Array with UnmodifiableListMixin { factory _ImmutableList._uninstantiable() { - throw new UnsupportedError( - "ImmutableArray can only be allocated by the VM", - ); + throw UnsupportedError("ImmutableArray can only be allocated by the VM"); } @pragma("vm:external-name", "ImmutableList_from") diff --git a/sdk/lib/_internal/vm/lib/async_patch.dart b/sdk/lib/_internal/vm/lib/async_patch.dart index 062899c8e23..718b018a477 100644 --- a/sdk/lib/_internal/vm/lib/async_patch.dart +++ b/sdk/lib/_internal/vm/lib/async_patch.dart @@ -141,7 +141,7 @@ class _AsyncStarStreamController { controller.close(); } - _AsyncStarStreamController() : controller = new StreamController(sync: true) { + _AsyncStarStreamController() : controller = StreamController(sync: true) { controller.onListen = this.onListen; controller.onResume = this.onResume; controller.onCancel = this.onCancel; @@ -164,7 +164,7 @@ class _AsyncStarStreamController { return null; } if (cancellationFuture == null) { - cancellationFuture = new _Future(); + cancellationFuture = _Future(); // Only resume the generator if it is suspended at a yield. // Cancellation does not affect an async generator that is // suspended at an await. diff --git a/sdk/lib/_internal/vm/lib/convert_patch.dart b/sdk/lib/_internal/vm/lib/convert_patch.dart index 6578f0fcbef..c30d4291359 100644 --- a/sdk/lib/_internal/vm/lib/convert_patch.dart +++ b/sdk/lib/_internal/vm/lib/convert_patch.dart @@ -28,8 +28,8 @@ dynamic _parseJson( String source, Object? Function(Object? key, Object? value)? reviver, ) { - _JsonListener listener = new _JsonListener(reviver); - var parser = new _JsonStringParser(listener); + _JsonListener listener = _JsonListener(reviver); + var parser = _JsonStringParser(listener); parser.chunk = source; parser.chunkEnd = source.length; parser.parse(0); @@ -42,7 +42,7 @@ class Utf8Decoder { @patch Converter, T> fuse(Converter next) { if (next is JsonDecoder) { - return new _JsonUtf8Decoder( + return _JsonUtf8Decoder( (next as JsonDecoder)._reviver, this._allowMalformed, ) @@ -66,7 +66,7 @@ class _JsonUtf8Decoder extends Converter, Object?> { } ByteConversionSink startChunkedConversion(Sink sink) { - return new _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed); + return _JsonUtf8DecoderSink(_reviver, sink, _allowMalformed); } } @@ -206,7 +206,7 @@ class _NumberBuffer { Uint8List list; int length = 0; _NumberBuffer(int initialCapacity) - : list = new Uint8List(_initialCapacity(initialCapacity)); + : list = Uint8List(_initialCapacity(initialCapacity)); int get capacity => list.length; @@ -229,13 +229,13 @@ class _NumberBuffer { void ensureCapacity(int newCapacity) { Uint8List list = this.list; if (newCapacity <= list.length) return; - Uint8List newList = new Uint8List(newCapacity); + Uint8List newList = Uint8List(newCapacity); newList.setRange(0, list.length, list, 0); this.list = newList; } String getString() { - String result = new String.fromCharCodes(list, 0, length); + String result = String.fromCharCodes(list, 0, length); return result; } @@ -1251,7 +1251,7 @@ mixin _ChunkedJsonParser on _JsonParserWithListener { int beginChunkNumber(int state, int start) { int end = chunkEnd; int length = end - start; - var buffer = new _NumberBuffer(length); + var buffer = _NumberBuffer(length); copyCharsToList(start, end, buffer.list, 0); buffer.length = length; this.buffer = buffer; @@ -1460,7 +1460,7 @@ mixin _ChunkedJsonParser on _JsonParserWithListener { message = "Unexpected character"; if (position == chunkEnd) message = "Unexpected end of input"; } - throw new FormatException(message, chunk, position); + throw FormatException(message, chunk, position); } } @@ -1486,7 +1486,7 @@ class _JsonStringParser extends _JsonParserWithListener } void beginString() { - this.buffer = new StringBuffer(); + this.buffer = StringBuffer(); } void addSliceToString(int start, int end) { @@ -1521,7 +1521,7 @@ class _JsonStringParser extends _JsonParserWithListener class JsonDecoder { @patch StringConversionSink startChunkedConversion(Sink sink) { - return new _JsonStringDecoderSink(this._reviver, sink); + return _JsonStringDecoderSink(this._reviver, sink); } } @@ -1542,7 +1542,7 @@ class _JsonStringDecoderSink extends StringConversionSinkBase { static _JsonStringParser _createParser( Object? Function(Object? key, Object? value)? reviver, ) { - return new _JsonStringParser(new _JsonListener(reviver)); + return _JsonStringParser(_JsonListener(reviver)); } void addSlice(String chunk, int start, int end, bool isLast) { @@ -1564,7 +1564,7 @@ class _JsonStringDecoderSink extends StringConversionSinkBase { } ByteConversionSink asUtf8Sink(bool allowMalformed) { - return new _JsonUtf8DecoderSink(_reviver, _sink, allowMalformed); + return _JsonUtf8DecoderSink(_reviver, _sink, allowMalformed); } } @@ -1580,7 +1580,7 @@ class _JsonUtf8Parser extends _JsonParserWithListener int chunkEnd = 0; _JsonUtf8Parser(_JsonListener listener, bool allowMalformed) - : decoder = new _Utf8Decoder(allowMalformed), + : decoder = _Utf8Decoder(allowMalformed), super(listener) { // Starts out checking for an optional BOM (KWD_BOM, count = 0). partialState = @@ -1621,7 +1621,7 @@ class _JsonUtf8Parser extends _JsonParserWithListener void beginString() { decoder.reset(); - this.buffer = new StringBuffer(); + this.buffer = StringBuffer(); } void addSliceToString(int start, int end) { @@ -1671,7 +1671,7 @@ class _JsonUtf8DecoderSink extends ByteConversionSink { Object? Function(Object? key, Object? value)? reviver, bool allowMalformed, ) { - return new _JsonUtf8Parser(new _JsonListener(reviver), allowMalformed); + return _JsonUtf8Parser(_JsonListener(reviver), allowMalformed); } void addSlice(List chunk, int start, int end, bool isLast) { diff --git a/sdk/lib/_internal/vm/lib/developer.dart b/sdk/lib/_internal/vm/lib/developer.dart index 5078932afb7..2f6063f4745 100644 --- a/sdk/lib/_internal/vm/lib/developer.dart +++ b/sdk/lib/_internal/vm/lib/developer.dart @@ -38,11 +38,11 @@ void log( StackTrace? stackTrace, }) { if (message is! String) { - throw new ArgumentError.value(message, "message", "Must be a String"); + throw ArgumentError.value(message, "message", "Must be a String"); } - time ??= new DateTime.now(); + time ??= DateTime.now(); if (time is! DateTime) { - throw new ArgumentError.value(time, "time", "Must be a DateTime"); + throw ArgumentError.value(time, "time", "Must be a DateTime"); } if (sequenceNumber == null) { sequenceNumber = _nextSequenceNumber++; @@ -92,7 +92,7 @@ external ServiceExtensionHandler? _lookupExtension(String method); external _registerExtension(String method, ServiceExtensionHandler handler); // This code is only invoked when there is no other Dart code on the stack. -@pragma("vm:entry-point", !const bool.fromEnvironment("dart.vm.product")) +@pragma("vm:entry-point", !bool.fromEnvironment("dart.vm.product")) _runExtension( ServiceExtensionHandler handler, String method, @@ -111,7 +111,7 @@ _runExtension( response = handler(method, parameters); } catch (e, st) { var errorDetails = (st == null) ? '$e' : '$e\n$st'; - response = new ServiceExtensionResponse.error( + response = ServiceExtensionResponse.error( ServiceExtensionResponse.extensionError, errorDetails, ); @@ -119,7 +119,7 @@ _runExtension( return; } if (response is! Future) { - response = new ServiceExtensionResponse.error( + response = ServiceExtensionResponse.error( ServiceExtensionResponse.extensionError, "Extension handler must return a Future", ); @@ -130,7 +130,7 @@ _runExtension( .catchError((e, st) { // Catch any errors eagerly and wrap them in a ServiceExtensionResponse. var errorDetails = (st == null) ? '$e' : '$e\n$st'; - return new ServiceExtensionResponse.error( + return ServiceExtensionResponse.error( ServiceExtensionResponse.extensionError, errorDetails, ); @@ -139,7 +139,7 @@ _runExtension( // Post the valid response or the wrapped error after verifying that // the response is a ServiceExtensionResponse. if (response is! ServiceExtensionResponse) { - response = new ServiceExtensionResponse.error( + response = ServiceExtensionResponse.error( ServiceExtensionResponse.extensionError, "Extension handler must complete to a ServiceExtensionResponse", ); @@ -169,7 +169,7 @@ _postResponse( return; } assert(id != null); - StringBuffer sb = new StringBuffer(); + StringBuffer sb = StringBuffer(); sb.write('{"jsonrpc":"2.0",'); if (response.isError()) { if (trace_service) { diff --git a/sdk/lib/_internal/vm/lib/double.dart b/sdk/lib/_internal/vm/lib/double.dart index 7afa43a18df..9a8ca17455e 100644 --- a/sdk/lib/_internal/vm/lib/double.dart +++ b/sdk/lib/_internal/vm/lib/double.dart @@ -139,29 +139,29 @@ final class _Double implements double { } double _addFromInteger(int other) { - return new _Double.fromInteger(other)._add(this); + return _Double.fromInteger(other)._add(this); } double _subFromInteger(int other) { - return new _Double.fromInteger(other)._sub(this); + return _Double.fromInteger(other)._sub(this); } @pragma("vm:recognized", "asm-intrinsic") @pragma("vm:exact-result-type", "dart:core#_Double") double _mulFromInteger(int other) { - return new _Double.fromInteger(other)._mul(this); + return _Double.fromInteger(other)._mul(this); } int _truncDivFromInteger(int other) { - return (new _Double.fromInteger(other) / this).truncate(); + return (_Double.fromInteger(other) / this).truncate(); } double _moduloFromInteger(int other) { - return new _Double.fromInteger(other)._modulo(this); + return _Double.fromInteger(other)._modulo(this); } double _remainderFromInteger(int other) { - return new _Double.fromInteger(other)._remainder(this); + return _Double.fromInteger(other)._remainder(this); } @pragma("vm:external-name", "Double_greaterThanFromInteger") @@ -223,13 +223,13 @@ final class _Double implements double { num clamp(num lowerLimit, num upperLimit) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (lowerLimit == null) { - throw new ArgumentError.notNull("lowerLimit"); + throw ArgumentError.notNull("lowerLimit"); } if (upperLimit == null) { - throw new ArgumentError.notNull("upperLimit"); + throw ArgumentError.notNull("upperLimit"); } if (lowerLimit.compareTo(upperLimit) > 0) { - throw new ArgumentError(lowerLimit); + throw ArgumentError(lowerLimit); } if (lowerLimit.isNaN) return lowerLimit; if (this.compareTo(lowerLimit) < 0) return lowerLimit; @@ -249,7 +249,7 @@ final class _Double implements double { static const int CACHE_LENGTH = 1 << (CACHE_SIZE_LOG2 + 1); static const int CACHE_MASK = CACHE_LENGTH - 1; // Each key (double) followed by its toString result. - static final List _cache = new List.filled(CACHE_LENGTH, null); + static final List _cache = List.filled(CACHE_LENGTH, null); static int _cacheEvictIndex = 0; @pragma("vm:external-name", "Double_toString") @@ -280,12 +280,12 @@ final class _Double implements double { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (fractionDigits == null) { - throw new ArgumentError.notNull("fractionDigits"); + throw ArgumentError.notNull("fractionDigits"); } // Step 2. if (fractionDigits < 0 || fractionDigits > 20) { - throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits"); + throw RangeError.range(fractionDigits, 0, 20, "fractionDigits"); } // Step 3. @@ -317,7 +317,7 @@ final class _Double implements double { // Step 7. if (fractionDigits != null) { if (fractionDigits < 0 || fractionDigits > 20) { - throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits"); + throw RangeError.range(fractionDigits, 0, 20, "fractionDigits"); } } @@ -339,7 +339,7 @@ final class _Double implements double { // See ECMAScript-262, 15.7.4.7 for details. if (precision == null) { - throw new ArgumentError.notNull("precision"); + throw ArgumentError.notNull("precision"); } // The EcmaScript specification checks for NaN and Infinity before looking // at the fractionDigits. In Dart we are consistent with toStringAsFixed and @@ -347,7 +347,7 @@ final class _Double implements double { // Step 8. if (precision < 1 || precision > 21) { - throw new RangeError.range(precision, 1, 21, "precision"); + throw RangeError.range(precision, 1, 21, "precision"); } if (isNaN) return "NaN"; diff --git a/sdk/lib/_internal/vm/lib/double_patch.dart b/sdk/lib/_internal/vm/lib/double_patch.dart index 0adb20f4f34..de1382f9eac 100644 --- a/sdk/lib/_internal/vm/lib/double_patch.dart +++ b/sdk/lib/_internal/vm/lib/double_patch.dart @@ -109,7 +109,7 @@ class double { static double parse(String source) { var result = _parse(source); if (result == null) { - throw new FormatException("Invalid double", source); + throw FormatException("Invalid double", source); } return result; } diff --git a/sdk/lib/_internal/vm/lib/errors_patch.dart b/sdk/lib/_internal/vm/lib/errors_patch.dart index a2a87c45722..812b7b82eb4 100644 --- a/sdk/lib/_internal/vm/lib/errors_patch.dart +++ b/sdk/lib/_internal/vm/lib/errors_patch.dart @@ -141,7 +141,7 @@ class _InternalError { @pragma("vm:entry-point") class UnsupportedError { static Never _throwNew(String msg) { - throw new UnsupportedError(msg); + throw UnsupportedError(msg); } } @@ -150,7 +150,7 @@ class UnsupportedError { class StateError { @pragma("vm:entry-point") static Never _throwNew(String msg) { - throw new StateError(msg); + throw StateError(msg); } } @@ -168,7 +168,7 @@ class NoSuchMethodError { NoSuchMethodError._withInvocation(this._receiver, this._invocation); static Never _throwNewInvocation(Object? receiver, Invocation invocation) { - throw new NoSuchMethodError.withInvocation(receiver, invocation); + throw NoSuchMethodError.withInvocation(receiver, invocation); } // The compiler emits a call to _throwNew when it cannot resolve a static @@ -184,7 +184,7 @@ class NoSuchMethodError { List? arguments, List? argumentNames, ) { - throw new NoSuchMethodError._withType( + throw NoSuchMethodError._withType( receiver, memberName, invocationType, @@ -200,11 +200,11 @@ class NoSuchMethodError { List arguments, List argumentNames, ) { - Map namedArguments = new Map(); + Map namedArguments = Map(); int numPositionalArguments = arguments.length - argumentNames.length; for (int i = 0; i < argumentNames.length; i++) { final argValue = arguments[numPositionalArguments + i]; - namedArguments[new Symbol(argumentNames[i])] = argValue; + namedArguments[Symbol(argumentNames[i])] = argValue; } return namedArguments; } @@ -222,8 +222,8 @@ class NoSuchMethodError { Object? typeArguments, List? arguments, List? argumentNames, - ) : this._invocation = new _InvocationMirror._withType( - new Symbol(memberName), + ) : this._invocation = _InvocationMirror._withType( + Symbol(memberName), invocationType, _InvocationMirror._unpackTypeArguments( typeArguments, @@ -262,7 +262,7 @@ class NoSuchMethodError { StringBuffer? typeArgumentsBuf = null; final typeArguments = localInvocation.typeArguments; if ((typeArguments != null) && (typeArguments.length > 0)) { - final argsBuf = new StringBuffer(); + final argsBuf = StringBuffer(); argsBuf.write("<"); for (int i = 0; i < typeArguments.length; i++) { if (i > 0) { @@ -273,7 +273,7 @@ class NoSuchMethodError { argsBuf.write(">"); typeArgumentsBuf = argsBuf; } - StringBuffer argumentsBuf = new StringBuffer(); + StringBuffer argumentsBuf = StringBuffer(); var positionalArguments = localInvocation.positionalArguments; int argumentCount = 0; if (positionalArguments != null) { @@ -320,7 +320,7 @@ class NoSuchMethodError { ])[kind]; } - StringBuffer msgBuf = new StringBuffer("NoSuchMethodError: "); + StringBuffer msgBuf = StringBuffer("NoSuchMethodError: "); bool isTypeCall = false; switch (level) { case _InvocationMirror._DYNAMIC: diff --git a/sdk/lib/_internal/vm/lib/expando_patch.dart b/sdk/lib/_internal/vm/lib/expando_patch.dart index 387240bc726..7c36d3ed4ac 100644 --- a/sdk/lib/_internal/vm/lib/expando_patch.dart +++ b/sdk/lib/_internal/vm/lib/expando_patch.dart @@ -20,11 +20,11 @@ class Expando { @patch Expando([String? name]) : name = name, - _data = new List<_WeakProperty?>.filled(_minSize, null), + _data = List<_WeakProperty?>.filled(_minSize, null), _used = 0; static const _minSize = 8; - static final _deletedEntry = new _WeakProperty(); + static final _deletedEntry = _WeakProperty(); @patch T? operator [](Object object) { @@ -93,7 +93,7 @@ class Expando { } if (_used < _limit) { - var ephemeron = new _WeakProperty(); + var ephemeron = _WeakProperty(); ephemeron.key = object; ephemeron.value = value; _data[idx] = ephemeron; @@ -130,7 +130,7 @@ class Expando { // Reset the mappings to empty so that we can just add the existing // valid entries. - _data = new List<_WeakProperty?>.filled(new_size, null); + _data = List<_WeakProperty?>.filled(new_size, null); _used = 0; for (var i = 0; i < old_data.length; i++) { diff --git a/sdk/lib/_internal/vm/lib/growable_array.dart b/sdk/lib/_internal/vm/lib/growable_array.dart index c512cc32a29..15007895e99 100644 --- a/sdk/lib/_internal/vm/lib/growable_array.dart +++ b/sdk/lib/_internal/vm/lib/growable_array.dart @@ -8,7 +8,7 @@ part of "core_patch.dart"; class _GrowableList extends ListBase { void insert(int index, T element) { if ((index < 0) || (index > length)) { - throw new RangeError.range(index, 0, length); + throw RangeError.range(index, 0, length); } int oldLength = this.length; add(element); @@ -41,7 +41,7 @@ class _GrowableList extends ListBase { void insertAll(int index, Iterable iterable) { if (index < 0 || index > length) { - throw new RangeError.range(index, 0, length); + throw RangeError.range(index, 0, length); } // TODO(floitsch): we can probably detect more cases. if (iterable is! List && iterable is! Set && iterable is! SubListIterable) { @@ -84,11 +84,11 @@ class _GrowableList extends ListBase { final int actualEnd = RangeError.checkValidRange(start, end, this.length); int length = actualEnd - start; if (length == 0) return []; - final list = new _List(length); + final list = _List(length); for (int i = 0; i < length; i++) { list[i] = this[start + i]; } - final result = new _GrowableList._withData(list); + final result = _GrowableList._withData(list); result._setLength(length); return result; } @@ -96,7 +96,7 @@ class _GrowableList extends ListBase { @pragma('dyn-module:language-impl:callable') factory _GrowableList(int length) { var data = _allocateData(length); - var result = new _GrowableList._withData(data); + var result = _GrowableList._withData(data); if (length > 0) { result._setLength(length); } @@ -105,7 +105,7 @@ class _GrowableList extends ListBase { factory _GrowableList.withCapacity(int capacity) { var data = _allocateData(capacity); - return new _GrowableList._withData(data); + return _GrowableList._withData(data); } // Specialization of List.empty constructor for growable == true. @@ -314,7 +314,7 @@ class _GrowableList extends ListBase { } if (isVMList) { if (identical(iterable, this)) { - throw new ConcurrentModificationError(this); + throw ConcurrentModificationError(this); } this._setLength(newLen); final ListBase iterableAsList = iterable as ListBase; @@ -332,7 +332,7 @@ class _GrowableList extends ListBase { this._setLength(newLen); this[len] = it.current; if (!it.moveNext()) return; - if (this.length != newLen) throw new ConcurrentModificationError(this); + if (this.length != newLen) throw ConcurrentModificationError(this); len = newLen; } _growToNextCapacity(); @@ -364,7 +364,7 @@ class _GrowableList extends ListBase { } // Shared array used as backing for new empty growable arrays. - static final _List _emptyList = new _List(0); + static final _List _emptyList = _List(0); static _List _allocateData(int capacity) { if (capacity == 0) { @@ -423,7 +423,7 @@ class _GrowableList extends ListBase { int initialLength = length; for (int i = 0; i < length; i++) { f(this[i]); - if (length != initialLength) throw new ConcurrentModificationError(this); + if (length != initialLength) throw ConcurrentModificationError(this); } } @@ -458,7 +458,7 @@ class _GrowableList extends ListBase { } // Not all elements are strings, so allocate a new backing array. - final list = new _List(length); + final list = _List(length); for (int copyIndex = 0; copyIndex < i; copyIndex++) { list[copyIndex] = this[copyIndex]; } @@ -485,7 +485,7 @@ class _GrowableList extends ListBase { } String _joinWithSeparator(String separator) { - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = StringBuffer(); buffer.write(this[0]); for (int i = 1; i < this.length; i++) { buffer.write(separator); @@ -512,7 +512,7 @@ class _GrowableList extends ListBase { @pragma("vm:prefer-inline") Iterator get iterator { - return new ListIterator(this); + return ListIterator(this); } List toList({bool growable = true}) { @@ -527,18 +527,18 @@ class _GrowableList extends ListBase { final length = this.length; if (growable) { if (length > 0) { - final data = new _List(_adjustedCapacity(length)); + final data = _List(_adjustedCapacity(length)); for (int i = 0; i < length; i++) { data[i] = this[i]; } - final result = new _GrowableList._withData(data); + final result = _GrowableList._withData(data); result._setLength(length); return result; } return []; } else { if (length > 0) { - final list = new _List(length); + final list = _List(length); for (int i = 0; i < length; i++) { list[i] = this[i]; } @@ -549,14 +549,14 @@ class _GrowableList extends ListBase { } Set toSet() { - return new Set.of(this); + return Set.of(this); } // Factory constructing a mutable List from a parser generated List literal. // [elements] contains elements that are already type checked. @pragma("vm:entry-point", "call") factory _GrowableList._literal(_List elements) { - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(elements.length); return result; } @@ -567,7 +567,7 @@ class _GrowableList extends ListBase { factory _GrowableList._literal1(T e0) { _List elements = _List(1); elements[0] = e0; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(1); return result; } @@ -577,7 +577,7 @@ class _GrowableList extends ListBase { _List elements = _List(2); elements[0] = e0; elements[1] = e1; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(2); return result; } @@ -588,7 +588,7 @@ class _GrowableList extends ListBase { elements[0] = e0; elements[1] = e1; elements[2] = e2; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(3); return result; } @@ -600,7 +600,7 @@ class _GrowableList extends ListBase { elements[1] = e1; elements[2] = e2; elements[3] = e3; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(4); return result; } @@ -613,7 +613,7 @@ class _GrowableList extends ListBase { elements[2] = e2; elements[3] = e3; elements[4] = e4; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(5); return result; } @@ -627,7 +627,7 @@ class _GrowableList extends ListBase { elements[3] = e3; elements[4] = e4; elements[5] = e5; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(6); return result; } @@ -642,7 +642,7 @@ class _GrowableList extends ListBase { elements[4] = e4; elements[5] = e5; elements[6] = e6; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(7); return result; } @@ -667,7 +667,7 @@ class _GrowableList extends ListBase { elements[5] = e5; elements[6] = e6; elements[7] = e7; - final result = new _GrowableList._withData(elements); + final result = _GrowableList._withData(elements); result._setLength(8); return result; } diff --git a/sdk/lib/_internal/vm/lib/integers.dart b/sdk/lib/_internal/vm/lib/integers.dart index a6fb086938b..1084285b6db 100644 --- a/sdk/lib/_internal/vm/lib/integers.dart +++ b/sdk/lib/_internal/vm/lib/integers.dart @@ -264,10 +264,10 @@ abstract final class _IntegerImplementation implements int { num clamp(num lowerLimit, num upperLimit) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (lowerLimit == null) { - throw new ArgumentError.notNull("lowerLimit"); + throw ArgumentError.notNull("lowerLimit"); } if (upperLimit == null) { - throw new ArgumentError.notNull("upperLimit"); + throw ArgumentError.notNull("upperLimit"); } // Special case for integers. if (lowerLimit is int && upperLimit is int && lowerLimit <= upperLimit) { @@ -277,7 +277,7 @@ abstract final class _IntegerImplementation implements int { } // Generic case involving doubles, and invalid integer ranges. if (lowerLimit.compareTo(upperLimit) > 0) { - throw new ArgumentError(lowerLimit); + throw ArgumentError(lowerLimit); } if (lowerLimit.isNaN) return lowerLimit; // Note that we don't need to care for -0.0 for the lower limit. @@ -293,7 +293,7 @@ abstract final class _IntegerImplementation implements int { @pragma("vm:recognized", "other") @pragma("vm:exact-result-type", _Double) double toDouble() { - return new _Double.fromInteger(this); + return _Double.fromInteger(this); } String toStringAsFixed(int fractionDigits) { @@ -312,7 +312,7 @@ abstract final class _IntegerImplementation implements int { String toRadixString(int radix) { if (radix < 2 || 36 < radix) { - throw new RangeError.range(radix, 2, 36, "radix"); + throw RangeError.range(radix, 2, 36, "radix"); } if (radix & (radix - 1) == 0) { return _toPow2String(radix); @@ -395,13 +395,13 @@ abstract final class _IntegerImplementation implements int { int modPow(int e, int m) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (e == null) { - throw new ArgumentError.notNull("exponent"); + throw ArgumentError.notNull("exponent"); } if (m == null) { - throw new ArgumentError.notNull("modulus"); + throw ArgumentError.notNull("modulus"); } - if (e < 0) throw new RangeError.range(e, 0, null, "exponent"); - if (m <= 0) throw new RangeError.range(m, 1, null, "modulus"); + if (e < 0) throw RangeError.range(e, 0, null, "exponent"); + if (m <= 0) throw RangeError.range(m, 1, null, "modulus"); if (e == 0) return 1; // This is floor(sqrt(2^63)). @@ -486,7 +486,7 @@ abstract final class _IntegerImplementation implements int { } while (u != 0); if (!inv) return v << s; if (v != 1) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } if (d < 0) { d += x; @@ -502,15 +502,15 @@ abstract final class _IntegerImplementation implements int { int modInverse(int m) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (m == null) { - throw new ArgumentError.notNull("modulus"); + throw ArgumentError.notNull("modulus"); } - if (m <= 0) throw new RangeError.range(m, 1, null, "modulus"); + if (m <= 0) throw RangeError.range(m, 1, null, "modulus"); if (m == 1) return 0; int t = this; if ((t < 0) || (t >= m)) t %= m; if (t == 1) return 1; if ((t == 0) || (t.isEven && m.isEven)) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } return _binaryGcd(m, t, true); } @@ -519,7 +519,7 @@ abstract final class _IntegerImplementation implements int { int gcd(int other) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (other == null) { - throw new ArgumentError.notNull("other"); + throw ArgumentError.notNull("other"); } int x = this.abs(); int y = other.abs(); @@ -558,7 +558,7 @@ final class _Smi extends _IntegerImplementation { * Get the digits of `n`, with `0 <= n < 100`, as * `_digitTable[n * 2]` and `_digitTable[n * 2 + 1]`. */ - static const _digitTable = const [ + static const _digitTable = [ 0x30, 0x30, 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, // 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30, 0x37, // 0x30, 0x38, 0x30, 0x39, 0x31, 0x30, 0x31, 0x31, // @@ -589,7 +589,7 @@ final class _Smi extends _IntegerImplementation { /** * Result of int.toString for -99, -98, ..., 98, 99. */ - static const _smallLookupTable = const [ + static const _smallLookupTable = [ "-99", "-98", "-97", "-96", "-95", "-94", "-93", "-92", "-91", "-90", // "-89", "-88", "-87", "-86", "-85", "-84", "-83", "-82", "-81", "-80", // "-79", "-78", "-77", "-76", "-75", "-74", "-73", "-72", "-71", "-70", // diff --git a/sdk/lib/_internal/vm/lib/internal_patch.dart b/sdk/lib/_internal/vm/lib/internal_patch.dart index fb3da3ece2e..ff2b2317c37 100644 --- a/sdk/lib/_internal/vm/lib/internal_patch.dart +++ b/sdk/lib/_internal/vm/lib/internal_patch.dart @@ -206,22 +206,22 @@ bool isSentinel(dynamic value) => throw UnsupportedError('isSentinel'); class LateError { @pragma("vm:entry-point") static Never _throwFieldAlreadyInitialized(String fieldName) { - throw new LateError.fieldAI(fieldName); + throw LateError.fieldAI(fieldName); } @pragma("vm:entry-point") static Never _throwLocalNotInitialized(String localName) { - throw new LateError.localNI(localName); + throw LateError.localNI(localName); } @pragma("vm:entry-point") static Never _throwLocalAlreadyInitialized(String localName) { - throw new LateError.localAI(localName); + throw LateError.localAI(localName); } @pragma("vm:entry-point") static Never _throwLocalAssignedDuringInitialization(String localName) { - throw new LateError.localADI(localName); + throw LateError.localADI(localName); } } @@ -234,7 +234,7 @@ void checkValidWeakTarget(object, name) { (object is Pointer) || (object is Struct) || (object is Union)) { - throw new ArgumentError.value( + throw ArgumentError.value( object, name, "Cannot be a string, number, boolean, record, null, Pointer, Struct or Union", diff --git a/sdk/lib/_internal/vm/lib/invocation_mirror_patch.dart b/sdk/lib/_internal/vm/lib/invocation_mirror_patch.dart index ee820e6f028..d285ddcbf8c 100644 --- a/sdk/lib/_internal/vm/lib/invocation_mirror_patch.dart +++ b/sdk/lib/_internal/vm/lib/invocation_mirror_patch.dart @@ -73,16 +73,14 @@ class _InvocationMirror implements Invocation { } if (funcName.startsWith("get:")) { _type |= _GETTER; - _memberName = new internal.Symbol.unvalidated(funcName.substring(4)); + _memberName = internal.Symbol.unvalidated(funcName.substring(4)); } else if (funcName.startsWith("set:")) { _type |= _SETTER; - _memberName = new internal.Symbol.unvalidated( - funcName.substring(4) + "=", - ); + _memberName = internal.Symbol.unvalidated(funcName.substring(4) + "="); } else { _type |= _isSuperInvocation ? (_SUPER << _LEVEL_SHIFT) | _METHOD : _METHOD; - _memberName = new internal.Symbol.unvalidated(funcName); + _memberName = internal.Symbol.unvalidated(funcName); } } @@ -130,7 +128,7 @@ class _InvocationMirror implements Invocation { // Exclude receiver and type args in the returned list. var receiverIndex = _typeArgsLen > 0 ? 1 : 0; var args = _arguments!; - _positionalArguments = new _ImmutableList._from( + _positionalArguments = _ImmutableList._from( args, receiverIndex + 1, numPositionalArguments, @@ -151,15 +149,15 @@ class _InvocationMirror implements Invocation { return _namedArguments = const {}; } var receiverIndex = _typeArgsLen > 0 ? 1 : 0; - final namedArguments = new Map(); + final namedArguments = Map(); for (var i = 0; i < numNamedArguments; i++) { var namedEntryIndex = _FIRST_NAMED_ENTRY + 2 * i; var pos = argsDescriptor[namedEntryIndex + 1] as int; var arg_name = argsDescriptor[namedEntryIndex] as String; var arg_value = _arguments![receiverIndex + pos]; - namedArguments[new internal.Symbol.unvalidated(arg_name)] = arg_value; + namedArguments[internal.Symbol.unvalidated(arg_name)] = arg_value; } - _namedArguments = new Map.unmodifiable(namedArguments); + _namedArguments = Map.unmodifiable(namedArguments); } return _namedArguments!; } @@ -218,7 +216,7 @@ class _InvocationMirror implements Invocation { bool isSuperInvocation, [ int type = _UNINITIALIZED, ]) { - return new _InvocationMirror( + return _InvocationMirror( functionName, argumentsDescriptor, arguments, @@ -240,7 +238,7 @@ class _InvocationMirror implements Invocation { int? type, int delayedTypeArgumentsLen, ) { - return new _InvocationMirror( + return _InvocationMirror( functionName, argumentsDescriptor, arguments, diff --git a/sdk/lib/_internal/vm/lib/isolate_patch.dart b/sdk/lib/_internal/vm/lib/isolate_patch.dart index ebb7cc74ca4..2fe09668c9b 100644 --- a/sdk/lib/_internal/vm/lib/isolate_patch.dart +++ b/sdk/lib/_internal/vm/lib/isolate_patch.dart @@ -16,12 +16,11 @@ part "timer_impl.dart"; @patch class ReceivePort { @patch - factory ReceivePort([String debugName = '']) => - new _ReceivePortImpl(debugName); + factory ReceivePort([String debugName = '']) => _ReceivePortImpl(debugName); @patch factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) { - return new _ReceivePortImpl.fromRawReceivePort(rawPort); + return _ReceivePortImpl.fromRawReceivePort(rawPort); } } @@ -29,7 +28,7 @@ class ReceivePort { @pragma("vm:entry-point") class Capability { @patch - factory Capability() => new _Capability(); + factory Capability() => _Capability(); } @pragma("vm:entry-point") @@ -62,7 +61,7 @@ class RawReceivePort { */ @patch factory RawReceivePort([Function? handler, String debugName = '']) { - _RawReceivePort result = new _RawReceivePort(debugName); + _RawReceivePort result = _RawReceivePort(debugName); result.handler = handler; return result; } @@ -70,10 +69,10 @@ class RawReceivePort { final class _ReceivePortImpl extends Stream implements ReceivePort { _ReceivePortImpl([String debugName = '']) - : this.fromRawReceivePort(new RawReceivePort(null, debugName)); + : this.fromRawReceivePort(RawReceivePort(null, debugName)); _ReceivePortImpl.fromRawReceivePort(this._rawPort) - : _controller = new StreamController(sync: true) { + : _controller = StreamController(sync: true) { _controller.onCancel = close; _rawPort.handler = _controller.add; } @@ -341,7 +340,7 @@ final class Isolate { static Uri? get packageConfigSync { var hook = VMLibraryHooks.packageConfigUriSync; if (hook == null) { - throw new UnsupportedError("Isolate.packageConfig"); + throw UnsupportedError("Isolate.packageConfig"); } return hook(); } @@ -355,7 +354,7 @@ final class Isolate { static Uri? resolvePackageUriSync(Uri packageUri) { var hook = VMLibraryHooks.resolvePackageUriSync; if (hook == null) { - throw new UnsupportedError("Isolate.resolvePackageUriSync"); + throw UnsupportedError("Isolate.resolvePackageUriSync"); } return hook(packageUri); } @@ -383,7 +382,7 @@ final class Isolate { if (script == null) { // We do not have enough information to support spawning the new // isolate. - throw new UnsupportedError("Isolate.spawn"); + throw UnsupportedError("Isolate.spawn"); } if (script.isScheme("package")) { if (Isolate._packageSupported()) { @@ -393,7 +392,7 @@ final class Isolate { } } - final RawReceivePort readyPort = new RawReceivePort( + final RawReceivePort readyPort = RawReceivePort( null, 'Isolate.spawn ready', ); @@ -413,7 +412,7 @@ final class Isolate { return await _spawnCommon(readyPort); } catch (e, st) { readyPort.close(); - return await new Future.error(e, st); + return await Future.error(e, st); } } @@ -448,20 +447,20 @@ final class Isolate { String? debugName, }) async { if (environment != null) { - throw new UnimplementedError("environment"); + throw UnimplementedError("environment"); } // Verify that no mutually exclusive arguments have been passed. if (automaticPackageResolution) { if (packageRoot != null) { - throw new ArgumentError( + throw ArgumentError( "Cannot simultaneously request " "automaticPackageResolution and specify a " "packageRoot.", ); } if (packageConfig != null) { - throw new ArgumentError( + throw ArgumentError( "Cannot simultaneously request " "automaticPackageResolution and specify a " "packageConfig.", @@ -469,7 +468,7 @@ final class Isolate { } } else { if ((packageRoot != null) && (packageConfig != null)) { - throw new ArgumentError( + throw ArgumentError( "Cannot simultaneously specify a " "packageRoot and a packageConfig.", ); @@ -497,7 +496,7 @@ final class Isolate { // The VM will invoke [_startIsolate] and not `main`. final packageConfigString = packageConfig?.toString(); - final RawReceivePort readyPort = new RawReceivePort( + final RawReceivePort readyPort = RawReceivePort( null, 'Isolate.spawnUri ready', ); @@ -526,14 +525,14 @@ final class Isolate { } static Future _spawnCommon(RawReceivePort readyPort) { - final completer = new Completer.sync(); + final completer = Completer.sync(); readyPort.handler = (readyMessage) { readyPort.close(); if (readyMessage is List && readyMessage.length == 2) { SendPort controlPort = readyMessage[0]; List capabilities = readyMessage[1]; completer.complete( - new Isolate( + Isolate( controlPort, pauseCapability: capabilities[0], terminateCapability: capabilities[1], @@ -542,12 +541,12 @@ final class Isolate { } else if (readyMessage is String) { // We encountered an error while starting the new isolate. completer.completeError( - new IsolateSpawnException('Unable to spawn isolate: ${readyMessage}'), + IsolateSpawnException('Unable to spawn isolate: ${readyMessage}'), ); } else { // This shouldn't happen. completer.completeError( - new IsolateSpawnException( + IsolateSpawnException( "Internal error: unexpected format for ready message: " "'${readyMessage}'", ), @@ -599,7 +598,7 @@ final class Isolate { // _sendOOB expects a fixed length array and hence we create a fixed // length array and assign values to it instead of using [ ... ]. var msg = - new List.filled(4, null) + List.filled(4, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _PAUSE @@ -611,7 +610,7 @@ final class Isolate { @patch void resume(Capability resumeCapability) { var msg = - new List.filled(4, null) + List.filled(4, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _RESUME @@ -623,7 +622,7 @@ final class Isolate { @patch void addOnExitListener(SendPort responsePort, {Object? response}) { var msg = - new List.filled(4, null) + List.filled(4, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _ADD_EXIT @@ -635,7 +634,7 @@ final class Isolate { @patch void removeOnExitListener(SendPort responsePort) { var msg = - new List.filled(3, null) + List.filled(3, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _DEL_EXIT @@ -646,7 +645,7 @@ final class Isolate { @patch void setErrorsFatal(bool errorsAreFatal) { var msg = - new List.filled(4, null) + List.filled(4, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _ERROR_FATAL @@ -658,7 +657,7 @@ final class Isolate { @patch void kill({int priority = beforeNextEvent}) { var msg = - new List.filled(4, null) + List.filled(4, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _KILL @@ -674,7 +673,7 @@ final class Isolate { int priority = immediate, }) { var msg = - new List.filled(5, null) + List.filled(5, null) ..[0] = 0 // Make room for OOM message type. ..[1] = _PING @@ -687,7 +686,7 @@ final class Isolate { @patch void addErrorListener(SendPort port) { var msg = - new List.filled(3, null) + List.filled(3, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _ADD_ERROR @@ -698,7 +697,7 @@ final class Isolate { @patch void removeErrorListener(SendPort port) { var msg = - new List.filled(3, null) + List.filled(3, null) ..[0] = 0 // Make room for OOB message type. ..[1] = _DEL_ERROR @@ -708,7 +707,7 @@ final class Isolate { static Isolate _getCurrentIsolate() { List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate(); - return new Isolate( + return Isolate( portAndCapabilities[0], pauseCapability: portAndCapabilities[1], terminateCapability: portAndCapabilities[2], diff --git a/sdk/lib/_internal/vm/lib/lib_prefix.dart b/sdk/lib/_internal/vm/lib/lib_prefix.dart index 1400eec2730..e434a79dbf8 100644 --- a/sdk/lib/_internal/vm/lib/lib_prefix.dart +++ b/sdk/lib/_internal/vm/lib/lib_prefix.dart @@ -20,7 +20,7 @@ class _LibraryPrefix { @pragma("vm:external-name", "LibraryPrefix_issueLoad") external static void _issueLoad(Object unit); - static final _loads = new Map>(); + static final _loads = Map>(); } class _DeferredNotLoadedError extends Error implements NoSuchMethodError { @@ -46,7 +46,7 @@ void _completeLoads(Object unit, String? errorMessage, bool transientError) { Completer? load = _LibraryPrefix._loads[unit]; if (load == null) { // Embedder loaded even though prefix.loadLibrary() wasn't called. - _LibraryPrefix._loads[unit] = load = new Completer(); + _LibraryPrefix._loads[unit] = load = Completer(); } if (errorMessage == null) { load.complete(null); @@ -54,7 +54,7 @@ void _completeLoads(Object unit, String? errorMessage, bool transientError) { if (transientError) { _LibraryPrefix._loads.remove(unit); } - load.completeError(new DeferredLoadException(errorMessage)); + load.completeError(DeferredLoadException(errorMessage)); } } @@ -69,7 +69,7 @@ Future _loadLibrary(_LibraryPrefix prefix) async { if (unit != 1) { Completer? load = _LibraryPrefix._loads[unit]; if (load == null) { - _LibraryPrefix._loads[unit] = load = new Completer(); + _LibraryPrefix._loads[unit] = load = Completer(); _LibraryPrefix._issueLoad(unit); } await load.future; @@ -78,7 +78,7 @@ Future _loadLibrary(_LibraryPrefix prefix) async { // Ensure the prefix's future does not complete until the next Turn even // when loading is a no-op or synchronous. Helps applications avoid writing // code that only works when loading isn't really deferred. - await new Future(() { + await Future(() { prefix._setLoaded(); }); } @@ -87,6 +87,6 @@ Future _loadLibrary(_LibraryPrefix prefix) async { @pragma("vm:never-inline") // Don't duplicate prefix checking code. void _checkLoaded(_LibraryPrefix prefix) { if (!prefix._isLoaded()) { - throw new _DeferredNotLoadedError(prefix); + throw _DeferredNotLoadedError(prefix); } } diff --git a/sdk/lib/_internal/vm/lib/math_patch.dart b/sdk/lib/_internal/vm/lib/math_patch.dart index a5a7960ff37..ea2832a8083 100644 --- a/sdk/lib/_internal/vm/lib/math_patch.dart +++ b/sdk/lib/_internal/vm/lib/math_patch.dart @@ -178,7 +178,7 @@ class Random { factory Random([int? seed]) { var state = _Random._setupSeed((seed == null) ? _Random._nextSeed() : seed); // Crank a couple of times to distribute the seed bits a bit further. - return new _Random._withState(state) + return _Random._withState(state) .._nextState() .._nextState() .._nextState() @@ -207,7 +207,7 @@ class _Random implements Random { int nextInt(int max) { const limit = 0x3FFFFFFF; if ((max <= 0) || ((max > limit) && (max > _POW2_32))) { - throw new RangeError.range( + throw RangeError.range( max, 1, _POW2_32, @@ -245,7 +245,7 @@ class _Random implements Random { static const _POW2_27_D = 1.0 * (1 << 27); // Use a singleton Random object to get a new seed if no seed was passed. - static final _prng = new _Random._withState(_initialSeed()); + static final _prng = _Random._withState(_initialSeed()); // Thomas Wang 64-bit mix. // http://www.concentric.net/~Ttwang/tech/inthash.htm diff --git a/sdk/lib/_internal/vm/lib/mirrors_impl.dart b/sdk/lib/_internal/vm/lib/mirrors_impl.dart index c0a7b29642b..ea32c24ec8b 100644 --- a/sdk/lib/_internal/vm/lib/mirrors_impl.dart +++ b/sdk/lib/_internal/vm/lib/mirrors_impl.dart @@ -15,12 +15,12 @@ class _InternalMirrorError extends Error { String _n(Symbol symbol) => internal.Symbol.getName(symbol as internal.Symbol); Symbol _s(String name) { - return new internal.Symbol.unvalidated(name); + return internal.Symbol.unvalidated(name); } Symbol? _sOpt(String? name) { if (name == null) return null; - return new internal.Symbol.unvalidated(name); + return internal.Symbol.unvalidated(name); } Symbol _computeQualifiedName(DeclarationMirror? owner, Symbol simpleName) { @@ -32,7 +32,7 @@ String _makeSignatureString( TypeMirror returnType, List parameters, ) { - StringBuffer buf = new StringBuffer(); + StringBuffer buf = StringBuffer(); buf.write('('); bool found_optional_positional = false; bool found_optional_named = false; @@ -78,25 +78,25 @@ List _wrapMetadata(List reflectees) { for (var reflectee in reflectees) { mirrors.add(reflect(reflectee)); } - return new UnmodifiableListView(mirrors); + return UnmodifiableListView(mirrors); } @pragma("vm:external-name", "TypeMirror_subtypeTest") external bool _subtypeTest(Type a, Type b); class _MirrorSystem extends MirrorSystem { - final TypeMirror dynamicType = new _SpecialTypeMirror._('dynamic'); - final TypeMirror voidType = new _SpecialTypeMirror._('void'); - final TypeMirror neverType = new _SpecialTypeMirror._('Never'); + final TypeMirror dynamicType = _SpecialTypeMirror._('dynamic'); + final TypeMirror voidType = _SpecialTypeMirror._('void'); + final TypeMirror neverType = _SpecialTypeMirror._('Never'); var _libraries; Map get libraries { if ((_libraries == null) || _dirty) { - _libraries = new Map(); + _libraries = Map(); for (LibraryMirror lib in _computeLibraries()) { _libraries[lib.uri] = lib; } - _libraries = new UnmodifiableMapView(_libraries); + _libraries = UnmodifiableMapView(_libraries); _dirty = false; } return _libraries; @@ -147,7 +147,7 @@ class _IsolateMirror extends Mirror implements IsolateMirror { var result = _loadUri(uri.toString()); if (result == null) { // Censored library. - throw new Exception("Cannot load $uri"); + throw Exception("Cannot load $uri"); } return result; } @@ -195,8 +195,8 @@ class _SyntheticAccessor implements MethodMirror { TypeMirror get returnType => _target.type; List get parameters { if (isGetter) return const []; - return new UnmodifiableListView([ - new _SyntheticSetterParameter(this, this._target), + return UnmodifiableListView([ + _SyntheticSetterParameter(this, this._target), ]); } @@ -247,9 +247,9 @@ abstract class _ObjectMirror extends Mirror implements ObjectMirror { int numPositionalArguments = positionalArguments.length; int numNamedArguments = namedArguments.length; int numArguments = numPositionalArguments + numNamedArguments; - List arguments = new List.filled(numArguments, null); + List arguments = List.filled(numArguments, null); arguments.setRange(0, numPositionalArguments, positionalArguments); - List names = new List.filled(numNamedArguments, null); + List names = List.filled(numNamedArguments, null); int argumentIndex = numPositionalArguments; int nameIndex = 0; if (numNamedArguments > 0) { @@ -343,10 +343,10 @@ class _InstanceMirror extends _ObjectMirror implements InstanceMirror { int numPositionalArguments = positionalArguments.length + 1; // Receiver. int numNamedArguments = namedArguments.length; int numArguments = numPositionalArguments + numNamedArguments; - List arguments = new List.filled(numArguments, null); + List arguments = List.filled(numArguments, null); arguments[0] = _reflectee; // Receiver. arguments.setRange(1, numPositionalArguments, positionalArguments); - List names = new List.filled(numNamedArguments, null); + List names = List.filled(numNamedArguments, null); int argumentIndex = numPositionalArguments; int nameIndex = 0; if (numNamedArguments > 0) { @@ -433,9 +433,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { bool get hasReflectedType => !_isGenericDeclaration; Type get reflectedType { if (!hasReflectedType) { - throw new UnsupportedError( - "Declarations of generics have no reflected type", - ); + throw UnsupportedError("Declarations of generics have no reflected type"); } return _reflectedType; } @@ -510,7 +508,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { for (var interfaceType in interfaceTypes) { interfaceMirrors.add(reflectType(interfaceType) as ClassMirror); } - return _superinterfaces = new UnmodifiableListView( + return _superinterfaces = UnmodifiableListView( interfaceMirrors, ); } @@ -550,7 +548,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { var m = _cachedStaticMembers; if (m != null) m; - var result = new Map(); + var result = Map(); var library = this.owner as LibraryMirror; declarations.values.forEach((decl) { if (decl is MethodMirror && decl.isStatic && !decl.isConstructor) { @@ -558,7 +556,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { } if (decl is VariableMirror && decl.isStatic) { var getterName = decl.simpleName; - result[getterName] = new _SyntheticAccessor( + result[getterName] = _SyntheticAccessor( this, getterName, true, @@ -568,7 +566,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { ); if (!decl.isFinal) { var setterName = _asSetter(decl.simpleName, library); - result[setterName] = new _SyntheticAccessor( + result[setterName] = _SyntheticAccessor( this, setterName, false, @@ -579,7 +577,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { } } }); - return _cachedStaticMembers = new UnmodifiableMapView( + return _cachedStaticMembers = UnmodifiableMapView( result, ); } @@ -589,7 +587,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { var m = _cachedInstanceMembers; if (m != null) return m; - var result = new Map(); + var result = Map(); var library = this.owner as LibraryMirror; var sup = superclass; if (sup != null) { @@ -604,7 +602,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { } if (decl is VariableMirror && !decl.isStatic) { var getterName = decl.simpleName; - result[getterName] = new _SyntheticAccessor( + result[getterName] = _SyntheticAccessor( this, getterName, true, @@ -614,7 +612,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { ); if (!decl.isFinal) { var setterName = _asSetter(decl.simpleName, library); - result[setterName] = new _SyntheticAccessor( + result[setterName] = _SyntheticAccessor( this, setterName, false, @@ -625,8 +623,9 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { } } }); - return _cachedInstanceMembers = - new UnmodifiableMapView(result); + return _cachedInstanceMembers = UnmodifiableMapView( + result, + ); } Map? _declarations; @@ -634,7 +633,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { var d = _declarations; if (d != null) return d; - var decls = new Map(); + var decls = Map(); var members = _computeMembers(mixin, _instantiator, _reflectee); for (var member in members) { @@ -652,7 +651,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { decls[typeVariable.simpleName] = typeVariable; } - return _declarations = new UnmodifiableMapView( + return _declarations = UnmodifiableMapView( decls, ); } @@ -677,12 +676,10 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { ClassMirror owner = originalDeclaration; var mirror; for (var i = 0; i < params.length; i += 2) { - mirror = new _TypeVariableMirror._(params[i + 1], params[i], owner); + mirror = _TypeVariableMirror._(params[i + 1], params[i], owner); result.add(mirror); } - return _typeVariables = new UnmodifiableListView( - result, - ); + return _typeVariables = UnmodifiableListView(result); } List? _typeArguments; @@ -694,7 +691,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { (!_isTransformedMixinApplication && _isAnonymousMixinApplication)) { return _typeArguments = const []; } else { - return _typeArguments = new UnmodifiableListView( + return _typeArguments = UnmodifiableListView( _computeTypeArguments(_reflectedType).cast(), ); } @@ -722,9 +719,9 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { int numPositionalArguments = positionalArguments.length; int numNamedArguments = namedArguments.length; int numArguments = numPositionalArguments + numNamedArguments; - List arguments = new List.filled(numArguments, null); + List arguments = List.filled(numArguments, null); arguments.setRange(0, numPositionalArguments, positionalArguments); - List names = new List.filled(numNamedArguments, null); + List names = List.filled(numNamedArguments, null); int argumentIndex = numPositionalArguments; int nameIndex = 0; if (numNamedArguments > 0) { @@ -777,7 +774,7 @@ class _ClassMirror extends _ObjectMirror implements ClassMirror, _TypeMirror { bool isSubclassOf(ClassMirror other) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. if (other == null) { - throw new ArgumentError.notNull('other'); + throw ArgumentError.notNull('other'); } ClassMirror otherDeclaration = other.originalDeclaration as ClassMirror; ClassMirror? c = this; @@ -886,7 +883,7 @@ class _FunctionTypeMirror extends _ClassMirror implements FunctionTypeMirror { List get parameters { var p = _parameters; if (p != null) return p; - return _parameters = new UnmodifiableListView( + return _parameters = UnmodifiableListView( _FunctionTypeMirror_parameters( _signatureReflectee, ).cast(), @@ -972,7 +969,7 @@ class _TypeVariableMirror extends _DeclarationMirror bool get hasReflectedType => false; Type get reflectedType { - throw new UnsupportedError('Type variables have no reflected type'); + throw UnsupportedError('Type variables have no reflected type'); } Type get _reflectedType => _reflectee; @@ -1044,13 +1041,13 @@ class _LibraryMirror extends _ObjectMirror implements LibraryMirror { var d = _declarations; if (d != null) return d; - var decls = new Map(); + var decls = Map(); var members = _computeMembers(_reflectee); for (var member in members) { decls[member.simpleName] = member; } - return _declarations = new UnmodifiableMapView( + return _declarations = UnmodifiableMapView( decls, ); } @@ -1076,7 +1073,7 @@ class _LibraryMirror extends _ObjectMirror implements LibraryMirror { var d = _cachedLibraryDependencies; if (d != null) return d; return _cachedLibraryDependencies = - new UnmodifiableListView( + UnmodifiableListView( _libraryDependencies(_reflectee).cast(), ); } @@ -1116,7 +1113,7 @@ class _LibraryDependencyMirror extends Mirror this.isDeferred, List unwrappedMetadata, ) : prefix = _sOpt(prefixString), - combinators = new UnmodifiableListView( + combinators = UnmodifiableListView( mutableCombinators.cast(), ), metadata = _wrapMetadata(unwrappedMetadata); @@ -1136,7 +1133,7 @@ class _LibraryDependencyMirror extends Mirror Future loadLibrary() { if (_targetMirrorOrPrefix is _LibraryMirror) { - return new Future.value(_targetMirrorOrPrefix); + return Future.value(_targetMirrorOrPrefix); } var savedPrefix = _targetMirrorOrPrefix; return savedPrefix.loadLibrary().then((_) { @@ -1155,7 +1152,7 @@ class _CombinatorMirror extends Mirror implements CombinatorMirror { final bool isShow; _CombinatorMirror._(identifierString, this.isShow) - : this.identifiers = new UnmodifiableListView([ + : this.identifiers = UnmodifiableListView([ _s(identifierString), ]); @@ -1206,7 +1203,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror { bool get isExtensionTypeMember => 0 != (_kindFlags & (1 << kExtensionTypeMember)); - static const _operators = const [ + static const _operators = [ "%", "&", "*", "+", "-", "/", "<", "<<", // "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/", @@ -1244,7 +1241,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror { List get parameters { var p = _parameters; if (p != null) return p; - return _parameters = new UnmodifiableListView( + return _parameters = UnmodifiableListView( _MethodMirror_parameters(_reflectee).cast(), ); } @@ -1261,7 +1258,7 @@ class _MethodMirror extends _DeclarationMirror implements MethodMirror { } else { var parts = MirrorSystem.getName(simpleName).split('.'); if (parts.length > 2) { - throw new _InternalMirrorError( + throw _InternalMirrorError( 'Internal error in MethodMirror.constructorName: ' 'malformed name <$simpleName>', ); @@ -1334,7 +1331,7 @@ class _VariableMirror extends _DeclarationMirror implements VariableMirror { } else if (o is _LibraryMirror) { return o._instantiator; } else { - throw new UnsupportedError("unexpected owner ${owner}"); + throw UnsupportedError("unexpected owner ${owner}"); } } @@ -1395,7 +1392,7 @@ class _ParameterMirror extends _VariableMirror implements ParameterMirror { bool get hasDefaultValue => _defaultValueReflectee != null; SourceLocation? get location { - throw new UnsupportedError("ParameterMirror.location unimplemented"); + throw UnsupportedError("ParameterMirror.location unimplemented"); } List get metadata { @@ -1440,7 +1437,7 @@ class _SpecialTypeMirror extends Mirror bool get hasReflectedType => simpleName == #dynamic; Type get reflectedType { if (simpleName == #dynamic) return dynamic; - throw new UnsupportedError("void has no reflected type"); + throw UnsupportedError("void has no reflected type"); } List get typeVariables => const []; @@ -1472,7 +1469,7 @@ class _SpecialTypeMirror extends Mirror } class _Mirrors { - static MirrorSystem _currentMirrorSystem = new _MirrorSystem(); + static MirrorSystem _currentMirrorSystem = _MirrorSystem(); static MirrorSystem currentMirrorSystem() { return _currentMirrorSystem; } @@ -1480,8 +1477,8 @@ class _Mirrors { // Creates a new local mirror for some Object. static InstanceMirror reflect(dynamic reflectee) { return reflectee is Function - ? new _ClosureMirror._(reflectee) - : new _InstanceMirror._(reflectee); + ? _ClosureMirror._(reflectee) + : _InstanceMirror._(reflectee); } @pragma("vm:external-name", "Mirrors_makeLocalClassMirror") @@ -1491,8 +1488,8 @@ class _Mirrors { @pragma("vm:external-name", "Mirrors_instantiateGenericType") external static Type _instantiateGenericType(Type key, typeArguments); - static Expando<_ClassMirror> _declarationCache = new Expando("ClassMirror"); - static Expando _instantiationCache = new Expando("TypeMirror"); + static Expando<_ClassMirror> _declarationCache = Expando("ClassMirror"); + static Expando _instantiationCache = Expando("TypeMirror"); static ClassMirror reflectClass(Type key) { var classMirror = _declarationCache[key]; @@ -1523,7 +1520,7 @@ class _Mirrors { static Type _instantiateType(Type key, List typeArguments) { if (typeArguments.isEmpty) { - throw new ArgumentError.value( + throw ArgumentError.value( typeArguments, 'typeArguments', 'Type arguments list cannot be empty.', diff --git a/sdk/lib/_internal/vm/lib/mirrors_patch.dart b/sdk/lib/_internal/vm/lib/mirrors_patch.dart index 7bfbafd489b..0d94520a1b1 100644 --- a/sdk/lib/_internal/vm/lib/mirrors_patch.dart +++ b/sdk/lib/_internal/vm/lib/mirrors_patch.dart @@ -66,12 +66,12 @@ class MirrorSystem { } if (candidates.length > 1) { var uris = candidates.map((lib) => lib.uri.toString()).toList(); - throw new Exception( + throw Exception( "There are multiple libraries named " "'${getName(libraryName)}': $uris", ); } - throw new Exception("There is no library named '${getName(libraryName)}'"); + throw Exception("There is no library named '${getName(libraryName)}'"); } @patch @@ -83,12 +83,12 @@ class MirrorSystem { static Symbol getSymbol(String name, [LibraryMirror? library]) { if ((library != null && library is! _LibraryMirror) || ((name.length > 0) && (name[0] == '_') && (library == null))) { - throw new ArgumentError(library); + throw ArgumentError(library); } if (library != null) { name = _mangleName(name, (library as _LibraryMirror)._reflectee); } - return new internal.Symbol.unvalidated(name); + return internal.Symbol.unvalidated(name); } @pragma("vm:external-name", "Mirrors_mangleName") diff --git a/sdk/lib/_internal/vm/lib/object_patch.dart b/sdk/lib/_internal/vm/lib/object_patch.dart index cb1ff949e18..44150d339e6 100644 --- a/sdk/lib/_internal/vm/lib/object_patch.dart +++ b/sdk/lib/_internal/vm/lib/object_patch.dart @@ -35,7 +35,7 @@ class Object { @pragma("vm:entry-point", "call") dynamic noSuchMethod(Invocation invocation) { // TODO(regis): Remove temp constructor identifier 'withInvocation'. - throw new NoSuchMethodError.withInvocation(this, invocation); + throw NoSuchMethodError.withInvocation(this, invocation); } @patch diff --git a/sdk/lib/_internal/vm/lib/print_patch.dart b/sdk/lib/_internal/vm/lib/print_patch.dart index 972283970ea..bc0b00d8f6c 100644 --- a/sdk/lib/_internal/vm/lib/print_patch.dart +++ b/sdk/lib/_internal/vm/lib/print_patch.dart @@ -14,7 +14,7 @@ void printToConsole(String line) { } void _unsupportedPrint(String line) { - throw new UnsupportedError("'print' is not supported"); + throw UnsupportedError("'print' is not supported"); } // _printClosure can be overwritten by the embedder to supply a different diff --git a/sdk/lib/_internal/vm/lib/profiler.dart b/sdk/lib/_internal/vm/lib/profiler.dart index ec7ed53aae9..9c0469056cf 100644 --- a/sdk/lib/_internal/vm/lib/profiler.dart +++ b/sdk/lib/_internal/vm/lib/profiler.dart @@ -8,7 +8,7 @@ part of "developer.dart"; class UserTag { @patch factory UserTag(String label) { - return new _UserTag(label); + return _UserTag(label); } @patch static UserTag get defaultTag => _getDefaultTag(); diff --git a/sdk/lib/_internal/vm/lib/regexp_patch.dart b/sdk/lib/_internal/vm/lib/regexp_patch.dart index 5a80d108e86..3e01bcd4a2a 100644 --- a/sdk/lib/_internal/vm/lib/regexp_patch.dart +++ b/sdk/lib/_internal/vm/lib/regexp_patch.dart @@ -14,7 +14,7 @@ class RegExp { bool unicode = false, bool dotAll = false, }) { - return new _RegExp( + return _RegExp( source, multiLine: multiLine, caseSensitive: caseSensitive, @@ -59,7 +59,7 @@ class RegExp { // If the text contains no characters needing escape, return it directly. if (escapeCharIndex == text.length) return text; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); int previousSliceEndIndex = 0; do { // Copy characters from previous escape to current escape into result. @@ -96,7 +96,7 @@ class _RegExpMatch implements RegExpMatch { String? group(int groupIdx) { if (groupIdx < 0 || groupIdx > _regexp._groupCount) { - throw new RangeError.value(groupIdx); + throw RangeError.value(groupIdx); } int startIndex = _start(groupIdx); int endIndex = _end(groupIdx); @@ -112,7 +112,7 @@ class _RegExpMatch implements RegExpMatch { } List groups(List groupsSpec) { - var groupsList = new List.filled(groupsSpec.length, null); + var groupsList = List.filled(groupsSpec.length, null); for (int i = 0; i < groupsSpec.length; i++) { groupsList[i] = group(groupsSpec[i]); } @@ -156,46 +156,46 @@ class _RegExp implements RegExp { RegExpMatch? firstMatch(String input) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (input == null) throw new ArgumentError.notNull('input'); + if (input == null) throw ArgumentError.notNull('input'); final match = _ExecuteMatch(input, 0); if (match == null) { return null; } - return new _RegExpMatch._(this, input, match); + return _RegExpMatch._(this, input, match); } Iterable allMatches(String string, [int start = 0]) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (string == null) throw new ArgumentError.notNull('string'); - if (start == null) throw new ArgumentError.notNull('start'); + if (string == null) throw ArgumentError.notNull('string'); + if (start == null) throw ArgumentError.notNull('start'); if (0 > start || start > string.length) { - throw new RangeError.range(start, 0, string.length); + throw RangeError.range(start, 0, string.length); } - return new _AllMatchesIterable(this, string, start); + return _AllMatchesIterable(this, string, start); } RegExpMatch? matchAsPrefix(String string, [int start = 0]) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (string == null) throw new ArgumentError.notNull('string'); - if (start == null) throw new ArgumentError.notNull('start'); + if (string == null) throw ArgumentError.notNull('string'); + if (start == null) throw ArgumentError.notNull('start'); if (start < 0 || start > string.length) { - throw new RangeError.range(start, 0, string.length); + throw RangeError.range(start, 0, string.length); } final list = _ExecuteMatchSticky(string, start); if (list == null) return null; - return new _RegExpMatch._(this, string, list); + return _RegExpMatch._(this, string, list); } bool hasMatch(String input) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (input == null) throw new ArgumentError.notNull('input'); + if (input == null) throw ArgumentError.notNull('input'); List? match = _ExecuteMatch(input, 0); return (match == null) ? false : true; } String? stringMatch(String input) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (input == null) throw new ArgumentError.notNull('input'); + if (input == null) throw ArgumentError.notNull('input'); List? match = _ExecuteMatch(input, 0); if (match == null) { return null; @@ -253,7 +253,7 @@ class _RegExp implements RegExp { // Byte map of one byte characters with a 0xff if the character is a word // character (digit, letter or underscore) and 0x00 otherwise. // Used by generated RegExp code. - static const List _wordCharacterMap = const [ + static const List _wordCharacterMap = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -337,8 +337,7 @@ class _AllMatchesIterable extends Iterable { _AllMatchesIterable(this._re, this._str, this._start); - Iterator get iterator => - new _AllMatchesIterator(_re, _str, _start); + Iterator get iterator => _AllMatchesIterator(_re, _str, _start); } class _AllMatchesIterator implements Iterator { @@ -365,7 +364,7 @@ class _AllMatchesIterator implements Iterator { if (_nextIndex <= _str.length) { final match = re._ExecuteMatch(_str, _nextIndex); if (match != null) { - var current = new _RegExpMatch._(re, _str, match); + var current = _RegExpMatch._(re, _str, match); _current = current; _nextIndex = current.end; if (_nextIndex == current.start) { diff --git a/sdk/lib/_internal/vm/lib/schedule_microtask_patch.dart b/sdk/lib/_internal/vm/lib/schedule_microtask_patch.dart index 956826e40c3..dd5bb1a4fc7 100644 --- a/sdk/lib/_internal/vm/lib/schedule_microtask_patch.dart +++ b/sdk/lib/_internal/vm/lib/schedule_microtask_patch.dart @@ -10,7 +10,7 @@ class _AsyncRun { static void _scheduleImmediate(void callback()) { final closure = _ScheduleImmediate._closure; if (closure == null) { - throw new UnsupportedError("Microtasks are not supported"); + throw UnsupportedError("Microtasks are not supported"); } closure(callback); } diff --git a/sdk/lib/_internal/vm/lib/string_patch.dart b/sdk/lib/_internal/vm/lib/string_patch.dart index cf8291ba45c..df611c392ff 100644 --- a/sdk/lib/_internal/vm/lib/string_patch.dart +++ b/sdk/lib/_internal/vm/lib/string_patch.dart @@ -20,8 +20,8 @@ class String { int? end, ]) { // TODO: Remove these null checks once all code is opted into strong nonnullable mode. - if (charCodes == null) throw new ArgumentError.notNull("charCodes"); - if (start == null) throw new ArgumentError.notNull("start"); + if (charCodes == null) throw ArgumentError.notNull("charCodes"); + if (start == null) throw ArgumentError.notNull("start"); return _StringBase.createFromCharCodes(charCodes, start, end, null); } @@ -43,7 +43,7 @@ class String { .._setAt(1, low); } } - throw new RangeError.range(charCode, 0, 0x10ffff); + throw RangeError.range(charCode, 0, 0x10ffff); } @patch @@ -96,7 +96,7 @@ abstract final class _StringBase implements String { static const int _maxJoinReplaceOneByteStringLength = 500; factory _StringBase._uninstantiable() { - throw new UnsupportedError("_StringBase can't be instantiated"); + throw UnsupportedError("_StringBase can't be instantiated"); } @pragma("vm:recognized", "asm-intrinsic") @@ -170,7 +170,7 @@ abstract final class _StringBase implements String { final int actualLimit = limit ?? _scanCodeUnits(typedCharCodes, start, end); if (actualLimit < 0) { - throw new ArgumentError(typedCharCodes); + throw ArgumentError(typedCharCodes); } if (actualLimit <= _maxLatin1) { return _createOneByteString(typedCharCodes, start, len); @@ -192,7 +192,7 @@ abstract final class _StringBase implements String { int bits = 0; for (int i = start; i < end; i++) { int code = charCodes[i]; - if (code is! _Smi) throw new ArgumentError(charCodes); + if (code is! _Smi) throw ArgumentError(charCodes); bits |= code; } return bits; @@ -375,7 +375,7 @@ abstract final class _StringBase implements String { bool startsWith(Pattern pattern, [int index = 0]) { if ((index < 0) || (index > this.length)) { - throw new RangeError.range(index, 0, this.length); + throw RangeError.range(index, 0, this.length); } if (pattern is String) { return _substringMatches(index, pattern); @@ -417,7 +417,7 @@ abstract final class _StringBase implements String { if (start == null) { start = this.length; } else if (start < 0 || start > this.length) { - throw new RangeError.range(start, 0, this.length); + throw RangeError.range(start, 0, this.length); } if (pattern is String) { String other = pattern; @@ -580,7 +580,7 @@ abstract final class _StringBase implements String { String operator *(int times) { if (times <= 0) return ""; if (times == 1) return this; - StringBuffer buffer = new StringBuffer(this); + StringBuffer buffer = StringBuffer(this); for (int i = 1; i < times; i++) { buffer.write(this); } @@ -590,7 +590,7 @@ abstract final class _StringBase implements String { String padLeft(int width, [String padding = ' ']) { int delta = width - this.length; if (delta <= 0) return this; - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = StringBuffer(); for (int i = 0; i < delta; i++) { buffer.write(padding); } @@ -601,7 +601,7 @@ abstract final class _StringBase implements String { String padRight(int width, [String padding = ' ']) { int delta = width - this.length; if (delta <= 0) return this; - StringBuffer buffer = new StringBuffer(this); + StringBuffer buffer = StringBuffer(this); for (int i = 0; i < delta; i++) { buffer.write(padding); } @@ -671,8 +671,8 @@ abstract final class _StringBase implements String { } String replaceAll(Pattern pattern, String replacement) { - if (pattern == null) throw new ArgumentError.notNull("pattern"); - if (replacement == null) throw new ArgumentError.notNull("replacement"); + if (pattern == null) throw ArgumentError.notNull("pattern"); + if (replacement == null) throw ArgumentError.notNull("replacement"); int startIndex = 0; // String fragments that replace the prefix [this] up to [startIndex]. @@ -770,8 +770,8 @@ abstract final class _StringBase implements String { ); String replaceAllMapped(Pattern pattern, String replace(Match match)) { - if (pattern == null) throw new ArgumentError.notNull("pattern"); - if (replace == null) throw new ArgumentError.notNull("replace"); + if (pattern == null) throw ArgumentError.notNull("pattern"); + if (replace == null) throw ArgumentError.notNull("replace"); List matches = []; int length = 0; int startIndex = 0; @@ -805,9 +805,9 @@ abstract final class _StringBase implements String { String replace(Match match), [ int startIndex = 0, ]) { - if (pattern == null) throw new ArgumentError.notNull("pattern"); - if (replace == null) throw new ArgumentError.notNull("replace"); - if (startIndex == null) throw new ArgumentError.notNull("startIndex"); + if (pattern == null) throw ArgumentError.notNull("pattern"); + if (replace == null) throw ArgumentError.notNull("replace"); + if (startIndex == null) throw ArgumentError.notNull("startIndex"); RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex"); var matches = pattern.allMatches(this, startIndex).iterator; @@ -825,12 +825,12 @@ abstract final class _StringBase implements String { String onNonMatch(String nonMatch), ) { // Pattern is the empty string. - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = StringBuffer(); int length = this.length; int i = 0; buffer.write(onNonMatch("")); while (i < length) { - buffer.write(onMatch(new _StringMatch(i, this, ""))); + buffer.write(onMatch(_StringMatch(i, this, ""))); // Special case to avoid splitting a surrogate pair. int code = this.codeUnitAt(i); if ((code & ~0x3FF) == 0xD800 && length > i + 1) { @@ -846,7 +846,7 @@ abstract final class _StringBase implements String { buffer.write(onNonMatch(this[i])); i++; } - buffer.write(onMatch(new _StringMatch(i, this, ""))); + buffer.write(onMatch(_StringMatch(i, this, ""))); buffer.write(onNonMatch("")); return buffer.toString(); } @@ -857,7 +857,7 @@ abstract final class _StringBase implements String { String onNonMatch(String nonMatch)?, }) { if (pattern == null) { - throw new ArgumentError.notNull("pattern"); + throw ArgumentError.notNull("pattern"); } onMatch ??= _matchString; onNonMatch ??= _stringIdentity; @@ -867,7 +867,7 @@ abstract final class _StringBase implements String { return _splitMapJoinEmptyString(onMatch, onNonMatch); } } - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = StringBuffer(); int startIndex = 0; for (Match match in pattern.allMatches(this)) { buffer.write(onNonMatch(this.substring(startIndex, match.start))); @@ -932,23 +932,19 @@ abstract final class _StringBase implements String { static ArgumentError _interpolationError(Object? o, Object? result) { // Since Dart 2.0, [result] can only be null. - return new ArgumentError.value( - o, - "object", - "toString method returned 'null'", - ); + return ArgumentError.value(o, "object", "toString method returned 'null'"); } Iterable allMatches(String string, [int start = 0]) { if (start < 0 || start > string.length) { - throw new RangeError.range(start, 0, string.length, "start"); + throw RangeError.range(start, 0, string.length, "start"); } - return new _StringAllMatchesIterable(string, this, start); + return _StringAllMatchesIterable(string, this, start); } Match? matchAsPrefix(String string, [int start = 0]) { if (start < 0 || start > string.length) { - throw new RangeError.range(start, 0, string.length); + throw RangeError.range(start, 0, string.length); } if (start + this.length > string.length) return null; for (int i = 0; i < this.length; i++) { @@ -956,12 +952,12 @@ abstract final class _StringBase implements String { return null; } } - return new _StringMatch(start, string, this); + return _StringMatch(start, string, this); } List split(Pattern pattern) { if ((pattern is String) && pattern.isEmpty) { - List result = new List.generate( + List result = List.generate( this.length, (int i) => this[i], ); @@ -999,9 +995,9 @@ abstract final class _StringBase implements String { return result; } - List get codeUnits => new CodeUnits(this); + List get codeUnits => CodeUnits(this); - Runes get runes => new Runes(this); + Runes get runes => Runes(this); @pragma("vm:external-name", "String_toUpperCase") external String toUpperCase(); @@ -1446,7 +1442,7 @@ final class _StringMatch implements Match { String group(int group) { if (group != 0) { - throw new RangeError.value(group); + throw RangeError.value(group); } return pattern; } @@ -1472,12 +1468,12 @@ final class _StringAllMatchesIterable extends Iterable { _StringAllMatchesIterable(this._input, this._pattern, this._index); Iterator get iterator => - new _StringAllMatchesIterator(_input, _pattern, _index); + _StringAllMatchesIterator(_input, _pattern, _index); Match get first { int index = _input.indexOf(_pattern, _index); if (index >= 0) { - return new _StringMatch(index, _input, _pattern); + return _StringMatch(index, _input, _pattern); } throw IterableElementError.noElement(); } @@ -1503,7 +1499,7 @@ final class _StringAllMatchesIterator implements Iterator { return false; } int end = index + _pattern.length; - _current = new _StringMatch(index, _input, _pattern); + _current = _StringMatch(index, _input, _pattern); // Empty match, don't start at same location again. if (end == _index) end++; _index = end; diff --git a/sdk/lib/_internal/vm/lib/symbol_patch.dart b/sdk/lib/_internal/vm/lib/symbol_patch.dart index 47667ded843..b9837ff409f 100644 --- a/sdk/lib/_internal/vm/lib/symbol_patch.dart +++ b/sdk/lib/_internal/vm/lib/symbol_patch.dart @@ -24,7 +24,7 @@ class Symbol { // Class._constructor@xxx -> Class._constructor // _Class@xxx._constructor@xxx -> _Class._constructor // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2 - StringBuffer result = new StringBuffer(); + StringBuffer result = StringBuffer(); bool add_setter_suffix = false; var pos = 0; if (string.length >= 4 && string[3] == ':') { diff --git a/sdk/lib/_internal/vm/lib/timer_impl.dart b/sdk/lib/_internal/vm/lib/timer_impl.dart index d430296c709..6de42705058 100644 --- a/sdk/lib/_internal/vm/lib/timer_impl.dart +++ b/sdk/lib/_internal/vm/lib/timer_impl.dart @@ -133,7 +133,7 @@ class _Timer implements Timer { // Timers are ordered by wakeup time. Timers with a timeout value of > 0 do // end up on the TimerHeap. Timers with a timeout of 0 are queued in a list. - static final _heap = new _TimerHeap(); + static final _heap = _TimerHeap(); static _Timer? _firstZeroTimer; static _Timer _lastZeroTimer = _sentinelTimer; @@ -198,7 +198,7 @@ class _Timer implements Timer { int now = VMLibraryHooks.timerMillisecondClock(); int wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds); - _Timer timer = new _Timer._internal( + _Timer timer = _Timer._internal( callback, wakeupTime, milliSeconds, @@ -491,9 +491,9 @@ class _Timer implements Timer { bool repeating, ) { if (repeating) { - return new _Timer.periodic(milliSeconds, callback); + return _Timer.periodic(milliSeconds, callback); } - return new _Timer(milliSeconds, callback); + return _Timer(milliSeconds, callback); } } diff --git a/sdk/lib/_internal/vm/lib/timer_patch.dart b/sdk/lib/_internal/vm/lib/timer_patch.dart index f1767a8dbf1..4842130c31f 100644 --- a/sdk/lib/_internal/vm/lib/timer_patch.dart +++ b/sdk/lib/_internal/vm/lib/timer_patch.dart @@ -10,7 +10,7 @@ class Timer { static Timer _createTimer(Duration duration, void callback()) { final factory = VMLibraryHooks.timerFactory; if (factory == null) { - throw new UnsupportedError("Timer interface not supported."); + throw UnsupportedError("Timer interface not supported."); } int milliseconds = duration.inMilliseconds; if (milliseconds < 0) milliseconds = 0; @@ -26,7 +26,7 @@ class Timer { ) { final factory = VMLibraryHooks.timerFactory; if (factory == null) { - throw new UnsupportedError("Timer interface not supported."); + throw UnsupportedError("Timer interface not supported."); } int milliseconds = duration.inMilliseconds; if (milliseconds < 0) milliseconds = 0; diff --git a/sdk/lib/_internal/vm/lib/typed_data_patch.dart b/sdk/lib/_internal/vm/lib/typed_data_patch.dart index 02d83ce3ff4..1e22f6b7a99 100644 --- a/sdk/lib/_internal/vm/lib/typed_data_patch.dart +++ b/sdk/lib/_internal/vm/lib/typed_data_patch.dart @@ -39,14 +39,14 @@ class ByteData implements TypedData { @patch @pragma("vm:recognized", "other") factory ByteData(int length) { - final list = new Uint8List(length) as _TypedList; + final list = Uint8List(length) as _TypedList; _rangeCheck(list.lengthInBytes, 0, length); - return new _ByteDataView._(list, 0, length); + return _ByteDataView._(list, 0, length); } factory ByteData._view(_TypedList typedData, int offsetInBytes, int length) { _rangeCheck(typedData.lengthInBytes, offsetInBytes, length); - return new _ByteDataView._(typedData, offsetInBytes, length); + return _ByteDataView._(typedData, offsetInBytes, length); } } @@ -69,7 +69,7 @@ abstract final class _TypedListBase { // Method(s) implementing the Collection interface. String join([String separator = ""]) { - StringBuffer buffer = new StringBuffer(); + StringBuffer buffer = StringBuffer(); buffer.writeAll(this as Iterable, separator); return buffer.toString(); } @@ -83,23 +83,23 @@ abstract final class _TypedListBase { // Method(s) implementing the List interface. set length(newLength) { - throw new UnsupportedError("Cannot resize a fixed-length list"); + throw UnsupportedError("Cannot resize a fixed-length list"); } void clear() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } bool remove(Object? element) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeRange(int start, int end) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void replaceRange(int start, int end, Iterable iterable) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } @pragma("vm:prefer-inline") @@ -235,10 +235,10 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { int get offsetInBytes; _ByteBuffer get buffer; - Iterable whereType() => new WhereTypeIterable(this); + Iterable whereType() => WhereTypeIterable(this); Iterable followedBy(Iterable other) => - new FollowedByIterable.firstEfficient(this, other); + FollowedByIterable.firstEfficient(this, other); List cast() => List.castFrom(this); void set first(int value) { @@ -279,7 +279,7 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { } void shuffle([Random? random]) { - random ??= new Random(); + random ??= Random(); var i = this.length; while (i > 1) { int pos = random.nextInt(i); @@ -290,35 +290,35 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { } } - Iterable where(bool f(int element)) => new WhereIterable(this, f); + Iterable where(bool f(int element)) => WhereIterable(this, f); - Iterable take(int n) => new SubListIterable(this, 0, n); + Iterable take(int n) => SubListIterable(this, 0, n); Iterable takeWhile(bool test(int element)) => - new TakeWhileIterable(this, test); + TakeWhileIterable(this, test); - Iterable skip(int n) => new SubListIterable(this, n, null); + Iterable skip(int n) => SubListIterable(this, n, null); Iterable skipWhile(bool test(int element)) => - new SkipWhileIterable(this, test); + SkipWhileIterable(this, test); - Iterable get reversed => new ReversedListIterable(this); + Iterable get reversed => ReversedListIterable(this); - Map asMap() => new ListMapView(this); + Map asMap() => ListMapView(this); Iterable getRange(int start, [int? end]) { int endIndex = RangeError.checkValidRange(start, end, this.length); - return new SubListIterable(this, start, endIndex); + return SubListIterable(this, start, endIndex); } - Iterator get iterator => new _TypedListIterator(this); + Iterator get iterator => _TypedListIterator(this); List toList({bool growable = true}) { - return new List.of(this, growable: growable); + return List.of(this, growable: growable); } Set toSet() { - return new Set.of(this); + return Set.of(this); } void forEach(void f(int element)) { @@ -346,10 +346,10 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { return initialValue; } - Iterable map(T f(int element)) => new MappedIterable(this, f); + Iterable map(T f(int element)) => MappedIterable(this, f); Iterable expand(Iterable f(int element)) => - new ExpandIterable(this, f); + ExpandIterable(this, f); bool every(bool f(int element)) { var len = this.length; @@ -413,19 +413,19 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { } void add(int value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void addAll(Iterable value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void insert(int index, int value) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void insertAll(int index, Iterable values) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void sort([int compare(int a, int b)?]) { @@ -454,19 +454,19 @@ base mixin _IntListMixin on _TypedListBase implements TypedDataList { } int removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } int removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeWhere(bool test(int element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void retainWhere(bool test(int element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } int get first { @@ -569,10 +569,10 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { int get offsetInBytes; _ByteBuffer get buffer; - Iterable whereType() => new WhereTypeIterable(this); + Iterable whereType() => WhereTypeIterable(this); Iterable followedBy(Iterable other) => - new FollowedByIterable.firstEfficient(this, other); + FollowedByIterable.firstEfficient(this, other); List cast() => List.castFrom(this); void set first(double value) { @@ -613,7 +613,7 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { } void shuffle([Random? random]) { - random ??= new Random(); + random ??= Random(); var i = this.length; while (i > 1) { int pos = random.nextInt(i); @@ -625,35 +625,35 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { } Iterable where(bool f(double element)) => - new WhereIterable(this, f); + WhereIterable(this, f); - Iterable take(int n) => new SubListIterable(this, 0, n); + Iterable take(int n) => SubListIterable(this, 0, n); Iterable takeWhile(bool test(double element)) => - new TakeWhileIterable(this, test); + TakeWhileIterable(this, test); - Iterable skip(int n) => new SubListIterable(this, n, null); + Iterable skip(int n) => SubListIterable(this, n, null); Iterable skipWhile(bool test(double element)) => - new SkipWhileIterable(this, test); + SkipWhileIterable(this, test); - Iterable get reversed => new ReversedListIterable(this); + Iterable get reversed => ReversedListIterable(this); - Map asMap() => new ListMapView(this); + Map asMap() => ListMapView(this); Iterable getRange(int start, [int? end]) { int endIndex = RangeError.checkValidRange(start, end, this.length); - return new SubListIterable(this, start, endIndex); + return SubListIterable(this, start, endIndex); } - Iterator get iterator => new _TypedListIterator(this); + Iterator get iterator => _TypedListIterator(this); List toList({bool growable = true}) { - return new List.of(this, growable: growable); + return List.of(this, growable: growable); } Set toSet() { - return new Set.of(this); + return Set.of(this); } void forEach(void f(double element)) { @@ -681,11 +681,10 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { return initialValue; } - Iterable map(T f(double element)) => - new MappedIterable(this, f); + Iterable map(T f(double element)) => MappedIterable(this, f); Iterable expand(Iterable f(double element)) => - new ExpandIterable(this, f); + ExpandIterable(this, f); bool every(bool f(double element)) { var len = this.length; @@ -749,19 +748,19 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { } void add(double value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void addAll(Iterable value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void insert(int index, double value) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void insertAll(int index, Iterable values) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void sort([int compare(double a, double b)?]) { @@ -790,19 +789,19 @@ base mixin _DoubleListMixin on _TypedListBase implements TypedDataList { } double removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } double removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeWhere(bool test(double element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void retainWhere(bool test(double element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } double get first { @@ -914,10 +913,10 @@ base mixin _Float32x4ListMixin on _TypedListBase Float32x4List _createList(int length); - Iterable whereType() => new WhereTypeIterable(this); + Iterable whereType() => WhereTypeIterable(this); Iterable followedBy(Iterable other) => - new FollowedByIterable.firstEfficient(this, other); + FollowedByIterable.firstEfficient(this, other); List cast() => List.castFrom(this); void set first(Float32x4 value) { @@ -958,7 +957,7 @@ base mixin _Float32x4ListMixin on _TypedListBase } void shuffle([Random? random]) { - random ??= new Random(); + random ??= Random(); var i = this.length; while (i > 1) { int pos = random.nextInt(i); @@ -1015,36 +1014,35 @@ base mixin _Float32x4ListMixin on _TypedListBase } Iterable where(bool f(Float32x4 element)) => - new WhereIterable(this, f); + WhereIterable(this, f); - Iterable take(int n) => new SubListIterable(this, 0, n); + Iterable take(int n) => SubListIterable(this, 0, n); Iterable takeWhile(bool test(Float32x4 element)) => - new TakeWhileIterable(this, test); + TakeWhileIterable(this, test); - Iterable skip(int n) => - new SubListIterable(this, n, null); + Iterable skip(int n) => SubListIterable(this, n, null); Iterable skipWhile(bool test(Float32x4 element)) => - new SkipWhileIterable(this, test); + SkipWhileIterable(this, test); - Iterable get reversed => new ReversedListIterable(this); + Iterable get reversed => ReversedListIterable(this); - Map asMap() => new ListMapView(this); + Map asMap() => ListMapView(this); Iterable getRange(int start, [int? end]) { int endIndex = RangeError.checkValidRange(start, end, this.length); - return new SubListIterable(this, start, endIndex); + return SubListIterable(this, start, endIndex); } - Iterator get iterator => new _TypedListIterator(this); + Iterator get iterator => _TypedListIterator(this); List toList({bool growable = true}) { - return new List.of(this, growable: growable); + return List.of(this, growable: growable); } Set toSet() { - return new Set.of(this); + return Set.of(this); } void forEach(void f(Float32x4 element)) { @@ -1073,10 +1071,10 @@ base mixin _Float32x4ListMixin on _TypedListBase } Iterable map(T f(Float32x4 element)) => - new MappedIterable(this, f); + MappedIterable(this, f); Iterable expand(Iterable f(Float32x4 element)) => - new ExpandIterable(this, f); + ExpandIterable(this, f); bool every(bool f(Float32x4 element)) { var len = this.length; @@ -1140,19 +1138,19 @@ base mixin _Float32x4ListMixin on _TypedListBase } void add(Float32x4 value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void addAll(Iterable value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void insert(int index, Float32x4 value) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void insertAll(int index, Iterable values) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void sort([int compare(Float32x4 a, Float32x4 b)?]) { @@ -1184,19 +1182,19 @@ base mixin _Float32x4ListMixin on _TypedListBase } Float32x4 removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Float32x4 removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeWhere(bool test(Float32x4 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void retainWhere(bool test(Float32x4 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Float32x4 get first { @@ -1256,10 +1254,10 @@ base mixin _Int32x4ListMixin on _TypedListBase Int32x4List _createList(int length); - Iterable whereType() => new WhereTypeIterable(this); + Iterable whereType() => WhereTypeIterable(this); Iterable followedBy(Iterable other) => - new FollowedByIterable.firstEfficient(this, other); + FollowedByIterable.firstEfficient(this, other); List cast() => List.castFrom(this); void set first(Int32x4 value) { @@ -1300,7 +1298,7 @@ base mixin _Int32x4ListMixin on _TypedListBase } void shuffle([Random? random]) { - random ??= new Random(); + random ??= Random(); var i = this.length; while (i > 1) { int pos = random.nextInt(i); @@ -1357,35 +1355,35 @@ base mixin _Int32x4ListMixin on _TypedListBase } Iterable where(bool f(Int32x4 element)) => - new WhereIterable(this, f); + WhereIterable(this, f); - Iterable take(int n) => new SubListIterable(this, 0, n); + Iterable take(int n) => SubListIterable(this, 0, n); Iterable takeWhile(bool test(Int32x4 element)) => - new TakeWhileIterable(this, test); + TakeWhileIterable(this, test); - Iterable skip(int n) => new SubListIterable(this, n, null); + Iterable skip(int n) => SubListIterable(this, n, null); Iterable skipWhile(bool test(Int32x4 element)) => - new SkipWhileIterable(this, test); + SkipWhileIterable(this, test); - Iterable get reversed => new ReversedListIterable(this); + Iterable get reversed => ReversedListIterable(this); - Map asMap() => new ListMapView(this); + Map asMap() => ListMapView(this); Iterable getRange(int start, [int? end]) { int endIndex = RangeError.checkValidRange(start, end, this.length); - return new SubListIterable(this, start, endIndex); + return SubListIterable(this, start, endIndex); } - Iterator get iterator => new _TypedListIterator(this); + Iterator get iterator => _TypedListIterator(this); List toList({bool growable = true}) { - return new List.of(this, growable: growable); + return List.of(this, growable: growable); } Set toSet() { - return new Set.of(this); + return Set.of(this); } void forEach(void f(Int32x4 element)) { @@ -1414,10 +1412,10 @@ base mixin _Int32x4ListMixin on _TypedListBase } Iterable map(T f(Int32x4 element)) => - new MappedIterable(this, f); + MappedIterable(this, f); Iterable expand(Iterable f(Int32x4 element)) => - new ExpandIterable(this, f); + ExpandIterable(this, f); bool every(bool f(Int32x4 element)) { var len = this.length; @@ -1481,19 +1479,19 @@ base mixin _Int32x4ListMixin on _TypedListBase } void add(Int32x4 value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void addAll(Iterable value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void insert(int index, Int32x4 value) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void insertAll(int index, Iterable values) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void sort([int compare(Int32x4 a, Int32x4 b)?]) { @@ -1525,19 +1523,19 @@ base mixin _Int32x4ListMixin on _TypedListBase } Int32x4 removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Int32x4 removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeWhere(bool test(Int32x4 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void retainWhere(bool test(Int32x4 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Int32x4 get first { @@ -1597,10 +1595,10 @@ base mixin _Float64x2ListMixin on _TypedListBase Float64x2List _createList(int length); - Iterable whereType() => new WhereTypeIterable(this); + Iterable whereType() => WhereTypeIterable(this); Iterable followedBy(Iterable other) => - new FollowedByIterable.firstEfficient(this, other); + FollowedByIterable.firstEfficient(this, other); List cast() => List.castFrom(this); void set first(Float64x2 value) { @@ -1641,7 +1639,7 @@ base mixin _Float64x2ListMixin on _TypedListBase } void shuffle([Random? random]) { - random ??= new Random(); + random ??= Random(); var i = this.length; while (i > 1) { int pos = random.nextInt(i); @@ -1698,36 +1696,35 @@ base mixin _Float64x2ListMixin on _TypedListBase } Iterable where(bool f(Float64x2 element)) => - new WhereIterable(this, f); + WhereIterable(this, f); - Iterable take(int n) => new SubListIterable(this, 0, n); + Iterable take(int n) => SubListIterable(this, 0, n); Iterable takeWhile(bool test(Float64x2 element)) => - new TakeWhileIterable(this, test); + TakeWhileIterable(this, test); - Iterable skip(int n) => - new SubListIterable(this, n, null); + Iterable skip(int n) => SubListIterable(this, n, null); Iterable skipWhile(bool test(Float64x2 element)) => - new SkipWhileIterable(this, test); + SkipWhileIterable(this, test); - Iterable get reversed => new ReversedListIterable(this); + Iterable get reversed => ReversedListIterable(this); - Map asMap() => new ListMapView(this); + Map asMap() => ListMapView(this); Iterable getRange(int start, [int? end]) { int endIndex = RangeError.checkValidRange(start, end, this.length); - return new SubListIterable(this, start, endIndex); + return SubListIterable(this, start, endIndex); } - Iterator get iterator => new _TypedListIterator(this); + Iterator get iterator => _TypedListIterator(this); List toList({bool growable = true}) { - return new List.of(this, growable: growable); + return List.of(this, growable: growable); } Set toSet() { - return new Set.of(this); + return Set.of(this); } void forEach(void f(Float64x2 element)) { @@ -1756,10 +1753,10 @@ base mixin _Float64x2ListMixin on _TypedListBase } Iterable map(T f(Float64x2 element)) => - new MappedIterable(this, f); + MappedIterable(this, f); Iterable expand(Iterable f(Float64x2 element)) => - new ExpandIterable(this, f); + ExpandIterable(this, f); bool every(bool f(Float64x2 element)) { var len = this.length; @@ -1823,19 +1820,19 @@ base mixin _Float64x2ListMixin on _TypedListBase } void add(Float64x2 value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void addAll(Iterable value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } void insert(int index, Float64x2 value) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void insertAll(int index, Iterable values) { - throw new UnsupportedError("Cannot insert into a fixed-length list"); + throw UnsupportedError("Cannot insert into a fixed-length list"); } void sort([int compare(Float64x2 a, Float64x2 b)?]) { @@ -1867,19 +1864,19 @@ base mixin _Float64x2ListMixin on _TypedListBase } Float64x2 removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Float64x2 removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void removeWhere(bool test(Float64x2 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } void retainWhere(bool test(Float64x2 element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } Float64x2 get first { @@ -1938,7 +1935,7 @@ final class _ByteBuffer implements ByteBuffer { _ByteBuffer(this._data); @pragma("vm:entry-point") - factory _ByteBuffer._New(data) => new _ByteBuffer(data); + factory _ByteBuffer._New(data) => _ByteBuffer(data); // Forward calls to _data. int get lengthInBytes => _data.lengthInBytes; @@ -1949,7 +1946,7 @@ final class _ByteBuffer implements ByteBuffer { ByteData asByteData([int offsetInBytes = 0, int? length]) { length ??= this.lengthInBytes - offsetInBytes; _rangeCheck(this._data.lengthInBytes, offsetInBytes, length); - return new _ByteDataView._(this._data, offsetInBytes, length); + return _ByteDataView._(this._data, offsetInBytes, length); } Int8List asInt8List([int offsetInBytes = 0, int? length]) { @@ -1959,7 +1956,7 @@ final class _ByteBuffer implements ByteBuffer { offsetInBytes, length * Int8List.bytesPerElement, ); - return new _Int8ArrayView._(this._data, offsetInBytes, length); + return _Int8ArrayView._(this._data, offsetInBytes, length); } Uint8List asUint8List([int offsetInBytes = 0, int? length]) { @@ -1970,7 +1967,7 @@ final class _ByteBuffer implements ByteBuffer { offsetInBytes, length * Uint8List.bytesPerElement, ); - return new _Uint8ArrayView._(this._data, offsetInBytes, length); + return _Uint8ArrayView._(this._data, offsetInBytes, length); } Uint8ClampedList asUint8ClampedList([int offsetInBytes = 0, int? length]) { @@ -1982,7 +1979,7 @@ final class _ByteBuffer implements ByteBuffer { offsetInBytes, length * Uint8ClampedList.bytesPerElement, ); - return new _Uint8ClampedArrayView._(this._data, offsetInBytes, length); + return _Uint8ClampedArrayView._(this._data, offsetInBytes, length); } Int16List asInt16List([int offsetInBytes = 0, int? length]) { @@ -1994,7 +1991,7 @@ final class _ByteBuffer implements ByteBuffer { length * Int16List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Int16List.bytesPerElement); - return new _Int16ArrayView._(this._data, offsetInBytes, length); + return _Int16ArrayView._(this._data, offsetInBytes, length); } Uint16List asUint16List([int offsetInBytes = 0, int? length]) { @@ -2006,7 +2003,7 @@ final class _ByteBuffer implements ByteBuffer { length * Uint16List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Uint16List.bytesPerElement); - return new _Uint16ArrayView._(this._data, offsetInBytes, length); + return _Uint16ArrayView._(this._data, offsetInBytes, length); } Int32List asInt32List([int offsetInBytes = 0, int? length]) { @@ -2018,7 +2015,7 @@ final class _ByteBuffer implements ByteBuffer { length * Int32List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Int32List.bytesPerElement); - return new _Int32ArrayView._(this._data, offsetInBytes, length); + return _Int32ArrayView._(this._data, offsetInBytes, length); } Uint32List asUint32List([int offsetInBytes = 0, int? length]) { @@ -2030,7 +2027,7 @@ final class _ByteBuffer implements ByteBuffer { length * Uint32List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Uint32List.bytesPerElement); - return new _Uint32ArrayView._(this._data, offsetInBytes, length); + return _Uint32ArrayView._(this._data, offsetInBytes, length); } Int64List asInt64List([int offsetInBytes = 0, int? length]) { @@ -2042,7 +2039,7 @@ final class _ByteBuffer implements ByteBuffer { length * Int64List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Int64List.bytesPerElement); - return new _Int64ArrayView._(this._data, offsetInBytes, length); + return _Int64ArrayView._(this._data, offsetInBytes, length); } Uint64List asUint64List([int offsetInBytes = 0, int? length]) { @@ -2054,7 +2051,7 @@ final class _ByteBuffer implements ByteBuffer { length * Uint64List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Uint64List.bytesPerElement); - return new _Uint64ArrayView._(this._data, offsetInBytes, length); + return _Uint64ArrayView._(this._data, offsetInBytes, length); } Float32List asFloat32List([int offsetInBytes = 0, int? length]) { @@ -2066,7 +2063,7 @@ final class _ByteBuffer implements ByteBuffer { length * Float32List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Float32List.bytesPerElement); - return new _Float32ArrayView._(this._data, offsetInBytes, length); + return _Float32ArrayView._(this._data, offsetInBytes, length); } Float64List asFloat64List([int offsetInBytes = 0, int? length]) { @@ -2078,7 +2075,7 @@ final class _ByteBuffer implements ByteBuffer { length * Float64List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Float64List.bytesPerElement); - return new _Float64ArrayView._(this._data, offsetInBytes, length); + return _Float64ArrayView._(this._data, offsetInBytes, length); } Float32x4List asFloat32x4List([int offsetInBytes = 0, int? length]) { @@ -2090,7 +2087,7 @@ final class _ByteBuffer implements ByteBuffer { length * Float32x4List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Float32x4List.bytesPerElement); - return new _Float32x4ArrayView._(this._data, offsetInBytes, length); + return _Float32x4ArrayView._(this._data, offsetInBytes, length); } Int32x4List asInt32x4List([int offsetInBytes = 0, int? length]) { @@ -2102,7 +2099,7 @@ final class _ByteBuffer implements ByteBuffer { length * Int32x4List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Int32x4List.bytesPerElement); - return new _Int32x4ArrayView._(this._data, offsetInBytes, length); + return _Int32x4ArrayView._(this._data, offsetInBytes, length); } Float64x2List asFloat64x2List([int offsetInBytes = 0, int? length]) { @@ -2114,7 +2111,7 @@ final class _ByteBuffer implements ByteBuffer { length * Float64x2List.bytesPerElement, ); _offsetAlignmentCheck(offsetInBytes, Float64x2List.bytesPerElement); - return new _Float64x2ArrayView._(this._data, offsetInBytes, length); + return _Float64x2ArrayView._(this._data, offsetInBytes, length); } } @@ -2130,7 +2127,7 @@ abstract final class _TypedList extends _TypedListBase { return length * elementSizeInBytes; } - _ByteBuffer get buffer => new _ByteBuffer(this); + _ByteBuffer get buffer => _ByteBuffer(this); // Internal utility methods. @@ -2344,8 +2341,7 @@ class Int8List { @patch factory Int8List.fromList(List elements) { - return new Int8List(elements.length) - ..setRange(0, elements.length, elements); + return Int8List(elements.length)..setRange(0, elements.length, elements); } } @@ -2380,7 +2376,7 @@ final class _Int8List extends _TypedList // Internal utility methods. Int8List _createList(int length) { - return new Int8List(length); + return Int8List(length); } @pragma("vm:prefer-inline") @@ -2402,8 +2398,7 @@ class Uint8List { @patch factory Uint8List.fromList(List elements) { - return new Uint8List(elements.length) - ..setRange(0, elements.length, elements); + return Uint8List(elements.length)..setRange(0, elements.length, elements); } } @@ -2438,7 +2433,7 @@ final class _Uint8List extends _TypedList // Internal utility methods. Uint8List _createList(int length) { - return new Uint8List(length); + return Uint8List(length); } @pragma("vm:prefer-inline") @@ -2463,7 +2458,7 @@ class Uint8ClampedList { @patch factory Uint8ClampedList.fromList(List elements) { - return new Uint8ClampedList(elements.length) + return Uint8ClampedList(elements.length) ..setRange(0, elements.length, elements); } } @@ -2500,7 +2495,7 @@ final class _Uint8ClampedList extends _TypedList // Internal utility methods. Uint8ClampedList _createList(int length) { - return new Uint8ClampedList(length); + return Uint8ClampedList(length); } @pragma("vm:prefer-inline") @@ -2528,8 +2523,7 @@ class Int16List { @patch factory Int16List.fromList(List elements) { - return new Int16List(elements.length) - ..setRange(0, elements.length, elements); + return Int16List(elements.length)..setRange(0, elements.length, elements); } } @@ -2577,7 +2571,7 @@ final class _Int16List extends _TypedList // Internal utility methods. Int16List _createList(int length) { - return new Int16List(length); + return Int16List(length); } @pragma("vm:prefer-inline") @@ -2599,8 +2593,7 @@ class Uint16List { @patch factory Uint16List.fromList(List elements) { - return new Uint16List(elements.length) - ..setRange(0, elements.length, elements); + return Uint16List(elements.length)..setRange(0, elements.length, elements); } } @@ -2648,7 +2641,7 @@ final class _Uint16List extends _TypedList // Internal utility methods. Uint16List _createList(int length) { - return new Uint16List(length); + return Uint16List(length); } @pragma("vm:prefer-inline") @@ -2670,8 +2663,7 @@ class Int32List { @patch factory Int32List.fromList(List elements) { - return new Int32List(elements.length) - ..setRange(0, elements.length, elements); + return Int32List(elements.length)..setRange(0, elements.length, elements); } } @@ -2705,7 +2697,7 @@ final class _Int32List extends _TypedList // Internal utility methods. Int32List _createList(int length) { - return new Int32List(length); + return Int32List(length); } @pragma("vm:prefer-inline") @@ -2727,8 +2719,7 @@ class Uint32List { @patch factory Uint32List.fromList(List elements) { - return new Uint32List(elements.length) - ..setRange(0, elements.length, elements); + return Uint32List(elements.length)..setRange(0, elements.length, elements); } } @@ -2762,7 +2753,7 @@ final class _Uint32List extends _TypedList // Internal utility methods. Uint32List _createList(int length) { - return new Uint32List(length); + return Uint32List(length); } @pragma("vm:prefer-inline") @@ -2784,8 +2775,7 @@ class Int64List { @patch factory Int64List.fromList(List elements) { - return new Int64List(elements.length) - ..setRange(0, elements.length, elements); + return Int64List(elements.length)..setRange(0, elements.length, elements); } } @@ -2819,7 +2809,7 @@ final class _Int64List extends _TypedList // Internal utility methods. Int64List _createList(int length) { - return new Int64List(length); + return Int64List(length); } @pragma("vm:prefer-inline") @@ -2841,8 +2831,7 @@ class Uint64List { @patch factory Uint64List.fromList(List elements) { - return new Uint64List(elements.length) - ..setRange(0, elements.length, elements); + return Uint64List(elements.length)..setRange(0, elements.length, elements); } } @@ -2876,7 +2865,7 @@ final class _Uint64List extends _TypedList // Internal utility methods. Uint64List _createList(int length) { - return new Uint64List(length); + return Uint64List(length); } @pragma("vm:prefer-inline") @@ -2898,8 +2887,7 @@ class Float32List { @patch factory Float32List.fromList(List elements) { - return new Float32List(elements.length) - ..setRange(0, elements.length, elements); + return Float32List(elements.length)..setRange(0, elements.length, elements); } } @@ -2934,7 +2922,7 @@ final class _Float32List extends _TypedList // Internal utility methods. Float32List _createList(int length) { - return new Float32List(length); + return Float32List(length); } @pragma("vm:prefer-inline") @@ -2956,8 +2944,7 @@ class Float64List { @patch factory Float64List.fromList(List elements) { - return new Float64List(elements.length) - ..setRange(0, elements.length, elements); + return Float64List(elements.length)..setRange(0, elements.length, elements); } } @@ -2992,7 +2979,7 @@ final class _Float64List extends _TypedList // Internal utility methods. Float64List _createList(int length) { - return new Float64List(length); + return Float64List(length); } @pragma("vm:prefer-inline") @@ -3014,7 +3001,7 @@ class Float32x4List { @patch factory Float32x4List.fromList(List elements) { - return new Float32x4List(elements.length) + return Float32x4List(elements.length) ..setRange(0, elements.length, elements); } } @@ -3049,7 +3036,7 @@ final class _Float32x4List extends _TypedList // Internal utility methods. Float32x4List _createList(int length) { - return new Float32x4List(length); + return Float32x4List(length); } @pragma("vm:prefer-inline") @@ -3071,8 +3058,7 @@ class Int32x4List { @patch factory Int32x4List.fromList(List elements) { - return new Int32x4List(elements.length) - ..setRange(0, elements.length, elements); + return Int32x4List(elements.length)..setRange(0, elements.length, elements); } } @@ -3106,7 +3092,7 @@ final class _Int32x4List extends _TypedList // Internal utility methods. Int32x4List _createList(int length) { - return new Int32x4List(length); + return Int32x4List(length); } @pragma("vm:prefer-inline") @@ -3128,7 +3114,7 @@ class Float64x2List { @patch factory Float64x2List.fromList(List elements) { - return new Float64x2List(elements.length) + return Float64x2List(elements.length) ..setRange(0, elements.length, elements); } } @@ -3163,7 +3149,7 @@ final class _Float64x2List extends _TypedList // Internal utility methods. Float64x2List _createList(int length) { - return new Float64x2List(length); + return Float64x2List(length); } @pragma("vm:prefer-inline") @@ -3205,7 +3191,7 @@ final class _ExternalInt8Array extends _TypedList // Internal utility methods. Int8List _createList(int length) { - return new Int8List(length); + return Int8List(length); } @pragma("vm:prefer-inline") @@ -3248,7 +3234,7 @@ final class _ExternalUint8Array extends _TypedList // Internal utility methods. Uint8List _createList(int length) { - return new Uint8List(length); + return Uint8List(length); } @pragma("vm:prefer-inline") @@ -3295,7 +3281,7 @@ final class _ExternalUint8ClampedArray extends _TypedList // Internal utility methods. Uint8ClampedList _createList(int length) { - return new Uint8ClampedList(length); + return Uint8ClampedList(length); } @pragma("vm:prefer-inline") @@ -3343,7 +3329,7 @@ final class _ExternalInt16Array extends _TypedList // Internal utility methods. Int16List _createList(int length) { - return new Int16List(length); + return Int16List(length); } @pragma("vm:prefer-inline") @@ -3385,7 +3371,7 @@ final class _ExternalUint16Array extends _TypedList // Internal utility methods. Uint16List _createList(int length) { - return new Uint16List(length); + return Uint16List(length); } @pragma("vm:prefer-inline") @@ -3426,7 +3412,7 @@ final class _ExternalInt32Array extends _TypedList // Internal utility methods. Int32List _createList(int length) { - return new Int32List(length); + return Int32List(length); } @pragma("vm:prefer-inline") @@ -3467,7 +3453,7 @@ final class _ExternalUint32Array extends _TypedList // Internal utility methods. Uint32List _createList(int length) { - return new Uint32List(length); + return Uint32List(length); } @pragma("vm:prefer-inline") @@ -3508,7 +3494,7 @@ final class _ExternalInt64Array extends _TypedList // Internal utility methods. Int64List _createList(int length) { - return new Int64List(length); + return Int64List(length); } @pragma("vm:prefer-inline") @@ -3549,7 +3535,7 @@ final class _ExternalUint64Array extends _TypedList // Internal utility methods. Uint64List _createList(int length) { - return new Uint64List(length); + return Uint64List(length); } @pragma("vm:prefer-inline") @@ -3591,7 +3577,7 @@ final class _ExternalFloat32Array extends _TypedList // Internal utility methods. Float32List _createList(int length) { - return new Float32List(length); + return Float32List(length); } @pragma("vm:prefer-inline") @@ -3633,7 +3619,7 @@ final class _ExternalFloat64Array extends _TypedList // Internal utility methods. Float64List _createList(int length) { - return new Float64List(length); + return Float64List(length); } @pragma("vm:prefer-inline") @@ -3675,7 +3661,7 @@ final class _ExternalFloat32x4Array extends _TypedList // Internal utility methods. Float32x4List _createList(int length) { - return new Float32x4List(length); + return Float32x4List(length); } @pragma("vm:prefer-inline") @@ -3717,7 +3703,7 @@ final class _ExternalInt32x4Array extends _TypedList // Internal utility methods. Int32x4List _createList(int length) { - return new Int32x4List(length); + return Int32x4List(length); } @pragma("vm:prefer-inline") @@ -3759,7 +3745,7 @@ final class _ExternalFloat64x2Array extends _TypedList // Internal utility methods. Float64x2List _createList(int length) { - return new Float64x2List(length); + return Float64x2List(length); } @pragma("vm:prefer-inline") @@ -4339,7 +4325,7 @@ final class _Int8ArrayView extends _TypedListView // Internal utility methods. Int8List _createList(int length) { - return new Int8List(length); + return Int8List(length); } @pragma("vm:prefer-inline") @@ -4392,7 +4378,7 @@ final class _Uint8ArrayView extends _TypedListView // Internal utility methods. Uint8List _createList(int length) { - return new Uint8List(length); + return Uint8List(length); } @pragma("vm:prefer-inline") @@ -4449,7 +4435,7 @@ final class _Uint8ClampedArrayView extends _TypedListView // Internal utility methods. Uint8ClampedList _createList(int length) { - return new Uint8ClampedList(length); + return Uint8ClampedList(length); } @pragma("vm:prefer-inline") @@ -4522,7 +4508,7 @@ final class _Int16ArrayView extends _TypedListView // Internal utility methods. Int16List _createList(int length) { - return new Int16List(length); + return Int16List(length); } @pragma("vm:prefer-inline") @@ -4589,7 +4575,7 @@ final class _Uint16ArrayView extends _TypedListView // Internal utility methods. Uint16List _createList(int length) { - return new Uint16List(length); + return Uint16List(length); } @pragma("vm:prefer-inline") @@ -4641,7 +4627,7 @@ final class _Int32ArrayView extends _TypedListView // Internal utility methods. Int32List _createList(int length) { - return new Int32List(length); + return Int32List(length); } @pragma("vm:prefer-inline") @@ -4693,7 +4679,7 @@ final class _Uint32ArrayView extends _TypedListView // Internal utility methods. Uint32List _createList(int length) { - return new Uint32List(length); + return Uint32List(length); } @pragma("vm:prefer-inline") @@ -4745,7 +4731,7 @@ final class _Int64ArrayView extends _TypedListView // Internal utility methods. Int64List _createList(int length) { - return new Int64List(length); + return Int64List(length); } @pragma("vm:prefer-inline") @@ -4797,7 +4783,7 @@ final class _Uint64ArrayView extends _TypedListView // Internal utility methods. Uint64List _createList(int length) { - return new Uint64List(length); + return Uint64List(length); } @pragma("vm:prefer-inline") @@ -4850,7 +4836,7 @@ final class _Float32ArrayView extends _TypedListView // Internal utility methods. Float32List _createList(int length) { - return new Float32List(length); + return Float32List(length); } @pragma("vm:prefer-inline") @@ -4903,7 +4889,7 @@ final class _Float64ArrayView extends _TypedListView // Internal utility methods. Float64List _createList(int length) { - return new Float64List(length); + return Float64List(length); } @pragma("vm:prefer-inline") @@ -4955,7 +4941,7 @@ final class _Float32x4ArrayView extends _TypedListView // Internal utility methods. Float32x4List _createList(int length) { - return new Float32x4List(length); + return Float32x4List(length); } @pragma("vm:prefer-inline") @@ -5007,7 +4993,7 @@ final class _Int32x4ArrayView extends _TypedListView // Internal utility methods. Int32x4List _createList(int length) { - return new Int32x4List(length); + return Int32x4List(length); } @pragma("vm:prefer-inline") @@ -5059,7 +5045,7 @@ final class _Float64x2ArrayView extends _TypedListView // Internal utility methods. Float64x2List _createList(int length) { - return new Float64x2List(length); + return Float64x2List(length); } @pragma("vm:prefer-inline") @@ -5390,10 +5376,10 @@ int _byteSwap64(int value) { return (_byteSwap32(value) << 32) | _byteSwap32(value >> 32); } -final _convU32 = new Uint32List(2); -final _convU64 = new Uint64List.view(_convU32.buffer); -final _convF32 = new Float32List.view(_convU32.buffer); -final _convF64 = new Float64List.view(_convU32.buffer); +final _convU32 = Uint32List(2); +final _convU64 = Uint64List.view(_convU32.buffer); +final _convF32 = Float32List.view(_convU32.buffer); +final _convF64 = Float64List.view(_convU32.buffer); // Top level utility methods. @pragma("vm:exact-result-type", "dart:core#_Smi") @@ -5408,7 +5394,7 @@ int _toClampedUint8(int value) { @pragma("vm:prefer-inline") int _typedDataIndexCheck(Object indexable, int index, int length) { if (index < 0 || index >= length) { - throw new IndexError.withLength( + throw IndexError.withLength( index, length, indexable: indexable, @@ -5423,7 +5409,7 @@ int _typedDataIndexCheck(Object indexable, int index, int length) { @pragma("vm:prefer-inline") int _byteDataByteOffsetCheck(ByteData indexable, int byteOffset, int length) { if (byteOffset < 0 || byteOffset >= length) { - throw new IndexError.withLength( + throw IndexError.withLength( byteOffset, length, indexable: indexable, @@ -5438,19 +5424,19 @@ int _byteDataByteOffsetCheck(ByteData indexable, int byteOffset, int length) { // otherwise). void _rangeCheck(int listLength, int start, int length) { if (length < 0) { - throw new RangeError.value(length); + throw RangeError.value(length); } if (start < 0) { - throw new RangeError.value(start); + throw RangeError.value(start); } if (start + length > listLength) { - throw new RangeError.value(start + length); + throw RangeError.value(start + length); } } void _offsetAlignmentCheck(int offset, int alignment) { if ((offset % alignment) != 0) { - throw new RangeError( + throw RangeError( 'Offset ($offset) must be a multiple of ' 'BYTES_PER_ELEMENT ($alignment)', ); @@ -5471,17 +5457,17 @@ final class _UnmodifiableInt8ArrayView extends _Int8ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableInt8ArrayView(Int8List list) => - new _UnmodifiableInt8ArrayView._( + _UnmodifiableInt8ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Int8List asUnmodifiableView() => this; } @@ -5500,17 +5486,17 @@ final class _UnmodifiableUint8ArrayView extends _Uint8ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableUint8ArrayView(Uint8List list) => - new _UnmodifiableUint8ArrayView._( + _UnmodifiableUint8ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Uint8List asUnmodifiableView() => this; } @@ -5529,17 +5515,17 @@ final class _UnmodifiableUint8ClampedArrayView extends _Uint8ClampedArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableUint8ClampedArrayView(Uint8ClampedList list) => - new _UnmodifiableUint8ClampedArrayView._( + _UnmodifiableUint8ClampedArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Uint8ClampedList asUnmodifiableView() => this; } @@ -5558,17 +5544,17 @@ final class _UnmodifiableInt16ArrayView extends _Int16ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableInt16ArrayView(Int16List list) => - new _UnmodifiableInt16ArrayView._( + _UnmodifiableInt16ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Int16List asUnmodifiableView() => this; } @@ -5587,17 +5573,17 @@ final class _UnmodifiableUint16ArrayView extends _Uint16ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableUint16ArrayView(Uint16List list) => - new _UnmodifiableUint16ArrayView._( + _UnmodifiableUint16ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Uint16List asUnmodifiableView() => this; } @@ -5616,17 +5602,17 @@ final class _UnmodifiableInt32ArrayView extends _Int32ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableInt32ArrayView(Int32List list) => - new _UnmodifiableInt32ArrayView._( + _UnmodifiableInt32ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Int32List asUnmodifiableView() => this; } @@ -5645,17 +5631,17 @@ final class _UnmodifiableUint32ArrayView extends _Uint32ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableUint32ArrayView(Uint32List list) => - new _UnmodifiableUint32ArrayView._( + _UnmodifiableUint32ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Uint32List asUnmodifiableView() => this; } @@ -5674,17 +5660,17 @@ final class _UnmodifiableInt64ArrayView extends _Int64ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableInt64ArrayView(Int64List list) => - new _UnmodifiableInt64ArrayView._( + _UnmodifiableInt64ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Int64List asUnmodifiableView() => this; } @@ -5703,17 +5689,17 @@ final class _UnmodifiableUint64ArrayView extends _Uint64ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableUint64ArrayView(Uint64List list) => - new _UnmodifiableUint64ArrayView._( + _UnmodifiableUint64ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Uint64List asUnmodifiableView() => this; } @@ -5732,17 +5718,17 @@ final class _UnmodifiableFloat32ArrayView extends _Float32ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableFloat32ArrayView(Float32List list) => - new _UnmodifiableFloat32ArrayView._( + _UnmodifiableFloat32ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, double value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Float32List asUnmodifiableView() => this; } @@ -5761,17 +5747,17 @@ final class _UnmodifiableFloat64ArrayView extends _Float64ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableFloat64ArrayView(Float64List list) => - new _UnmodifiableFloat64ArrayView._( + _UnmodifiableFloat64ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, double value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Float64List asUnmodifiableView() => this; } @@ -5790,17 +5776,17 @@ final class _UnmodifiableFloat32x4ArrayView extends _Float32x4ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableFloat32x4ArrayView(Float32x4List list) => - new _UnmodifiableFloat32x4ArrayView._( + _UnmodifiableFloat32x4ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, Float32x4 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Float32x4List asUnmodifiableView() => this; } @@ -5819,17 +5805,17 @@ final class _UnmodifiableInt32x4ArrayView extends _Int32x4ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableInt32x4ArrayView(Int32x4List list) => - new _UnmodifiableInt32x4ArrayView._( + _UnmodifiableInt32x4ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, Int32x4 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Int32x4List asUnmodifiableView() => this; } @@ -5848,17 +5834,17 @@ final class _UnmodifiableFloat64x2ArrayView extends _Float64x2ArrayView { @pragma("vm:prefer-inline") factory _UnmodifiableFloat64x2ArrayView(Float64x2List list) => - new _UnmodifiableFloat64x2ArrayView._( + _UnmodifiableFloat64x2ArrayView._( unsafeCast<_TypedListBase>(list)._typedData, list.offsetInBytes, list.length, ); void operator []=(int index, Float64x2 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); Float64x2List asUnmodifiableView() => this; } @@ -5877,50 +5863,50 @@ final class _UnmodifiableByteDataView extends _ByteDataView { @pragma("vm:prefer-inline") factory _UnmodifiableByteDataView(ByteData data) => - new _UnmodifiableByteDataView._( + _UnmodifiableByteDataView._( unsafeCast<_ByteDataView>(data).buffer._data, data.offsetInBytes, data.lengthInBytes, ); void setInt8(int byteOffset, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setUint8(int byteOffset, int value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setInt16(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setUint16(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setInt32(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setUint32(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setInt64(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setUint64(int byteOffset, int value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setFloat32(int byteOffset, double value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setFloat64(int byteOffset, double value, [Endian endian = Endian.big]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } void setFloat32x4( @@ -5928,10 +5914,10 @@ final class _UnmodifiableByteDataView extends _ByteDataView { Float32x4 value, [ Endian endian = Endian.big, ]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } - _ByteBuffer get buffer => new _UnmodifiableByteBufferView(_typedData.buffer); + _ByteBuffer get buffer => _UnmodifiableByteBufferView(_typedData.buffer); ByteData asUnmodifiableView() => this; } @@ -5941,65 +5927,53 @@ final class _UnmodifiableByteBufferView extends _ByteBuffer { : super(unsafeCast<_ByteBuffer>(data)._data); Uint8List asUint8List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableUint8ArrayView(super.asUint8List(offsetInBytes, length)); + _UnmodifiableUint8ArrayView(super.asUint8List(offsetInBytes, length)); Int8List asInt8List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableInt8ArrayView(super.asInt8List(offsetInBytes, length)); + _UnmodifiableInt8ArrayView(super.asInt8List(offsetInBytes, length)); Uint8ClampedList asUint8ClampedList([int offsetInBytes = 0, int? length]) => - new _UnmodifiableUint8ClampedArrayView( + _UnmodifiableUint8ClampedArrayView( super.asUint8ClampedList(offsetInBytes, length), ); Uint16List asUint16List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableUint16ArrayView( - super.asUint16List(offsetInBytes, length), - ); + _UnmodifiableUint16ArrayView(super.asUint16List(offsetInBytes, length)); Int16List asInt16List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableInt16ArrayView(super.asInt16List(offsetInBytes, length)); + _UnmodifiableInt16ArrayView(super.asInt16List(offsetInBytes, length)); Uint32List asUint32List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableUint32ArrayView( - super.asUint32List(offsetInBytes, length), - ); + _UnmodifiableUint32ArrayView(super.asUint32List(offsetInBytes, length)); Int32List asInt32List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableInt32ArrayView(super.asInt32List(offsetInBytes, length)); + _UnmodifiableInt32ArrayView(super.asInt32List(offsetInBytes, length)); Uint64List asUint64List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableUint64ArrayView( - super.asUint64List(offsetInBytes, length), - ); + _UnmodifiableUint64ArrayView(super.asUint64List(offsetInBytes, length)); Int64List asInt64List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableInt64ArrayView(super.asInt64List(offsetInBytes, length)); + _UnmodifiableInt64ArrayView(super.asInt64List(offsetInBytes, length)); Int32x4List asInt32x4List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableInt32x4ArrayView( - super.asInt32x4List(offsetInBytes, length), - ); + _UnmodifiableInt32x4ArrayView(super.asInt32x4List(offsetInBytes, length)); Float32List asFloat32List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableFloat32ArrayView( - super.asFloat32List(offsetInBytes, length), - ); + _UnmodifiableFloat32ArrayView(super.asFloat32List(offsetInBytes, length)); Float64List asFloat64List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableFloat64ArrayView( - super.asFloat64List(offsetInBytes, length), - ); + _UnmodifiableFloat64ArrayView(super.asFloat64List(offsetInBytes, length)); Float32x4List asFloat32x4List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableFloat32x4ArrayView( + _UnmodifiableFloat32x4ArrayView( super.asFloat32x4List(offsetInBytes, length), ); Float64x2List asFloat64x2List([int offsetInBytes = 0, int? length]) => - new _UnmodifiableFloat64x2ArrayView( + _UnmodifiableFloat64x2ArrayView( super.asFloat64x2List(offsetInBytes, length), ); ByteData asByteData([int offsetInBytes = 0, int? length]) => - new _UnmodifiableByteDataView(super.asByteData(offsetInBytes, length)); + _UnmodifiableByteDataView(super.asByteData(offsetInBytes, length)); } diff --git a/sdk/lib/_internal/vm/lib/uri_patch.dart b/sdk/lib/_internal/vm/lib/uri_patch.dart index 740ee277405..fdac9439990 100644 --- a/sdk/lib/_internal/vm/lib/uri_patch.dart +++ b/sdk/lib/_internal/vm/lib/uri_patch.dart @@ -7,7 +7,7 @@ part of "core_patch.dart"; typedef Uri _UriBaseClosure(); Uri _unsupportedUriBase() { - throw new UnsupportedError("'Uri.base' is not supported"); + throw UnsupportedError("'Uri.base' is not supported"); } // _uriBaseClosure can be overwritten by the embedder to supply a different @@ -57,7 +57,7 @@ class _Uri { // Encode the string into bytes then generate an ASCII only string // by percent encoding selected bytes. - StringBuffer result = new StringBuffer(); + StringBuffer result = StringBuffer(); for (int j = 0; j < i; j++) { result.writeCharCode(text.codeUnitAt(j)); } diff --git a/sdk/lib/_internal/vm_shared/lib/bigint_patch.dart b/sdk/lib/_internal/vm_shared/lib/bigint_patch.dart index cfee4aefb5b..cd3b41f788c 100644 --- a/sdk/lib/_internal/vm_shared/lib/bigint_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/bigint_patch.dart @@ -56,14 +56,14 @@ class BigInt implements Comparable { _BigIntImpl._tryParse(source, radix: radix); @patch - factory BigInt.from(num value) => new _BigIntImpl.from(value); + factory BigInt.from(num value) => _BigIntImpl.from(value); } int _max(int a, int b) => a > b ? a : b; int _min(int a, int b) => a < b ? a : b; /// Allocate a new digits list of even length. -Uint32List _newDigits(int length) => new Uint32List(length + (length & 1)); +Uint32List _newDigits(int length) => Uint32List(length + (length & 1)); /** * An implementation for the arbitrarily large integer. @@ -81,14 +81,14 @@ class _BigIntImpl implements BigInt { static const int _halfDigitBits = _digitBits >> 1; static const int _halfDigitMask = (1 << _halfDigitBits) - 1; - static final _BigIntImpl zero = new _BigIntImpl._fromInt(0); - static final _BigIntImpl one = new _BigIntImpl._fromInt(1); - static final _BigIntImpl two = new _BigIntImpl._fromInt(2); + static final _BigIntImpl zero = _BigIntImpl._fromInt(0); + static final _BigIntImpl one = _BigIntImpl._fromInt(1); + static final _BigIntImpl two = _BigIntImpl._fromInt(2); static final _BigIntImpl _minusOne = -one; - static final _BigIntImpl _oneDigitMask = new _BigIntImpl._fromInt(_digitMask); + static final _BigIntImpl _oneDigitMask = _BigIntImpl._fromInt(_digitMask); static final _BigIntImpl _twoDigitMask = (one << (2 * _digitBits)) - one; - static final _BigIntImpl _oneBillion = new _BigIntImpl._fromInt(1000000000); + static final _BigIntImpl _oneBillion = _BigIntImpl._fromInt(1000000000); static const int _minInt = -0x8000000000000000; static const int _maxInt = 0x7fffffffffffffff; @@ -101,7 +101,7 @@ class _BigIntImpl implements BigInt { /// Note that [_isIntrinsified] is still false if intrinsification occurs, /// so it should be used only inside methods which are replaced by /// intrinsification. - static final bool _isIntrinsified = new bool.fromEnvironment( + static final bool _isIntrinsified = bool.fromEnvironment( 'dart.vm.not.a.compile.time.constant', ); @@ -167,7 +167,7 @@ class _BigIntImpl implements BigInt { static _BigIntImpl parse(String source, {int? radix}) { var result = _tryParse(source, radix: radix); if (result == null) { - throw new FormatException("Could not parse BigInt", source); + throw FormatException("Could not parse BigInt", source); } return result; } @@ -188,7 +188,7 @@ class _BigIntImpl implements BigInt { for (int i = 0; i < source.length; i++) { part = part * 10 + source.codeUnitAt(i) - _0; if (++digitInPartCount == 9) { - result = result * _oneBillion + new _BigIntImpl._fromInt(part); + result = result * _oneBillion + _BigIntImpl._fromInt(part); part = 0; digitInPartCount = 0; } @@ -252,7 +252,7 @@ class _BigIntImpl implements BigInt { digits[digitIndex--] = digit; } if (used == 1 && digits[0] == 0) return zero; - return new _BigIntImpl._(isNegative, used, digits); + return _BigIntImpl._(isNegative, used, digits); } /// Parses the given [source] as a [radix] literal. @@ -261,11 +261,11 @@ class _BigIntImpl implements BigInt { /// this function returns `null`. static _BigIntImpl? _parseRadix(String source, int radix, bool isNegative) { var result = zero; - var base = new _BigIntImpl._fromInt(radix); + var base = _BigIntImpl._fromInt(radix); for (int i = 0; i < source.length; i++) { var value = _codeUnitToRadixValue(source.codeUnitAt(i)); if (value >= radix) return null; - result = result * base + new _BigIntImpl._fromInt(value); + result = result * base + _BigIntImpl._fromInt(value); } if (isNegative) return -result; return result; @@ -305,7 +305,7 @@ class _BigIntImpl implements BigInt { } if (radix < 2 || radix > 36) { - throw new RangeError.range(radix, 2, 36, 'radix'); + throw RangeError.range(radix, 2, 36, 'radix'); } if (radix == 10 && decimalMatch != null) { return _parseDecimal(decimalMatch, isNegative); @@ -372,12 +372,12 @@ class _BigIntImpl implements BigInt { if (value == 2) return two; if (value.abs() < 0x100000000) { - return new _BigIntImpl._fromInt(value.toInt()); + return _BigIntImpl._fromInt(value.toInt()); } if (value is double) { - return new _BigIntImpl._fromDouble(value); + return _BigIntImpl._fromDouble(value); } - return new _BigIntImpl._fromInt(value as int); + return _BigIntImpl._fromInt(value as int); } factory _BigIntImpl._fromInt(int value) { @@ -389,28 +389,28 @@ class _BigIntImpl implements BigInt { // positive. if (value == _minInt) { digits[1] = 0x80000000; - return new _BigIntImpl._(true, 2, digits); + return _BigIntImpl._(true, 2, digits); } value = -value; } if (value < _digitBase) { digits[0] = value; - return new _BigIntImpl._(isNegative, 1, digits); + return _BigIntImpl._(isNegative, 1, digits); } digits[0] = value & _digitMask; digits[1] = value >> _digitBits; - return new _BigIntImpl._(isNegative, 2, digits); + return _BigIntImpl._(isNegative, 2, digits); } /// An 8-byte Uint8List we can reuse for [_fromDouble] to avoid generating /// garbage. - static final Uint8List _bitsForFromDouble = new Uint8List(8); + static final Uint8List _bitsForFromDouble = Uint8List(8); factory _BigIntImpl._fromDouble(double value) { const int exponentBias = 1075; if (value.isNaN || value.isInfinite) { - throw new ArgumentError("Value must be finite: $value"); + throw ArgumentError("Value must be finite: $value"); } bool isNegative = value < 0; if (isNegative) value = -value; @@ -436,7 +436,7 @@ class _BigIntImpl implements BigInt { unshiftedDigits[1] = ((0x10 | (bits[6] & 0xF)) << 16) + (bits[5] << 8) + bits[4]; - var unshiftedBig = new _BigIntImpl._normalized(false, 2, unshiftedDigits); + var unshiftedBig = _BigIntImpl._normalized(false, 2, unshiftedDigits); _BigIntImpl absResult = unshiftedBig; if (exponent < 0) { absResult = unshiftedBig >> -exponent; @@ -455,7 +455,7 @@ class _BigIntImpl implements BigInt { */ _BigIntImpl operator -() { if (_used == 0) return this; - return new _BigIntImpl._(!_isNegative, _used, _digits); + return _BigIntImpl._(!_isNegative, _used, _digits); } /** @@ -477,7 +477,7 @@ class _BigIntImpl implements BigInt { for (int i = used - 1; i >= 0; i--) { resultDigits[i + n] = digits[i]; } - return new _BigIntImpl._(_isNegative, resultUsed, resultDigits); + return _BigIntImpl._(_isNegative, resultUsed, resultDigits); } /// Same as [_dlShift] but works on the decomposed big integers. @@ -526,7 +526,7 @@ class _BigIntImpl implements BigInt { for (var i = n; i < used; i++) { resultDigits[i - n] = digits[i]; } - final result = new _BigIntImpl._(_isNegative, resultUsed, resultDigits); + final result = _BigIntImpl._(_isNegative, resultUsed, resultDigits); if (_isNegative) { // Round down if any bit was shifted out. for (var i = 0; i < n; i++) { @@ -607,7 +607,7 @@ class _BigIntImpl implements BigInt { */ _BigIntImpl operator <<(int shiftAmount) { if (shiftAmount < 0) { - throw new ArgumentError("shift-amount must be positive $shiftAmount"); + throw ArgumentError("shift-amount must be positive $shiftAmount"); } if (_isZero) return this; final digitShift = shiftAmount ~/ _digitBits; @@ -620,7 +620,7 @@ class _BigIntImpl implements BigInt { // The 64-bit intrinsic requires one extra pair to work with. var resultDigits = _newDigits(resultUsed + 1); _lsh(_digits, _used, shiftAmount, resultDigits); - return new _BigIntImpl._(_isNegative, resultUsed, resultDigits); + return _BigIntImpl._(_isNegative, resultUsed, resultDigits); } /// resultDigits[0..resultUsed-1] = xDigits[0..xUsed-1] << n. @@ -690,7 +690,7 @@ class _BigIntImpl implements BigInt { */ _BigIntImpl operator >>(int shiftAmount) { if (shiftAmount < 0) { - throw new ArgumentError("shift-amount must be positive $shiftAmount"); + throw ArgumentError("shift-amount must be positive $shiftAmount"); } if (_isZero) return this; final digitShift = shiftAmount ~/ _digitBits; @@ -707,7 +707,7 @@ class _BigIntImpl implements BigInt { // The 64-bit intrinsic requires one extra pair to work with. final resultDigits = _newDigits(resultUsed + 1); _rsh(digits, used, shiftAmount, resultDigits); - final result = new _BigIntImpl._(_isNegative, resultUsed, resultDigits); + final result = _BigIntImpl._(_isNegative, resultUsed, resultDigits); if (_isNegative) { // Round down if any bit was shifted out. if ((digits[digitShift] & ((1 << bitShift) - 1)) != 0) { @@ -867,7 +867,7 @@ class _BigIntImpl implements BigInt { var resultUsed = used + 1; var resultDigits = _newDigits(resultUsed); _absAdd(_digits, used, other._digits, otherUsed, resultDigits); - return new _BigIntImpl._(isNegative, resultUsed, resultDigits); + return _BigIntImpl._(isNegative, resultUsed, resultDigits); } /// Returns `abs(this) - abs(other)` with sign set according to [isNegative]. @@ -886,7 +886,7 @@ class _BigIntImpl implements BigInt { } var resultDigits = _newDigits(used); _absSub(_digits, used, other._digits, otherUsed, resultDigits); - return new _BigIntImpl._(isNegative, used, resultDigits); + return _BigIntImpl._(isNegative, used, resultDigits); } /// Returns `abs(this) & abs(other)` with sign set according to [isNegative]. @@ -898,7 +898,7 @@ class _BigIntImpl implements BigInt { for (var i = 0; i < resultUsed; i++) { resultDigits[i] = digits[i] & otherDigits[i]; } - return new _BigIntImpl._(isNegative, resultUsed, resultDigits); + return _BigIntImpl._(isNegative, resultUsed, resultDigits); } /// Returns `abs(this) &~ abs(other)` with sign set according to [isNegative]. @@ -914,7 +914,7 @@ class _BigIntImpl implements BigInt { for (var i = m; i < resultUsed; i++) { resultDigits[i] = digits[i]; } - return new _BigIntImpl._(isNegative, resultUsed, resultDigits); + return _BigIntImpl._(isNegative, resultUsed, resultDigits); } /// Returns `abs(this) | abs(other)` with sign set according to [isNegative]. @@ -940,7 +940,7 @@ class _BigIntImpl implements BigInt { for (var i = m; i < resultUsed; i++) { resultDigits[i] = lDigits[i]; } - return new _BigIntImpl._(isNegative, resultUsed, resultDigits); + return _BigIntImpl._(isNegative, resultUsed, resultDigits); } /// Returns `abs(this) ^ abs(other)` with sign set according to [isNegative]. @@ -966,7 +966,7 @@ class _BigIntImpl implements BigInt { for (var i = m; i < resultUsed; i++) { resultDigits[i] = lDigits[i]; } - return new _BigIntImpl._(isNegative, resultUsed, resultDigits); + return _BigIntImpl._(isNegative, resultUsed, resultDigits); } /** @@ -1283,7 +1283,7 @@ class _BigIntImpl implements BigInt { while (i < otherUsed) { i += _mulAdd(otherDigits, i, digits, 0, resultDigits, i, used); } - return new _BigIntImpl._( + return _BigIntImpl._( _isNegative != other._isNegative, resultUsed, resultDigits, @@ -1396,7 +1396,7 @@ class _BigIntImpl implements BigInt { _lastQuoRemUsed, lastQuo_used, ); - var quo = new _BigIntImpl._(false, lastQuo_used, quo_digits); + var quo = _BigIntImpl._(false, lastQuo_used, quo_digits); if ((_isNegative != other._isNegative) && (quo._used > 0)) { quo = -quo; } @@ -1419,7 +1419,7 @@ class _BigIntImpl implements BigInt { _lastRemUsed, _lastRemUsed, ); - var rem = new _BigIntImpl._(false, _lastRemUsed, remDigits); + var rem = _BigIntImpl._(false, _lastRemUsed, remDigits); if (_lastRem_nsh > 0) { rem = rem >> _lastRem_nsh; // Denormalize remainder. } @@ -1869,7 +1869,7 @@ class _BigIntImpl implements BigInt { _BigIntImpl pow(int exponent) { if (exponent < 0) { - throw new ArgumentError("Exponent must not be negative: $exponent"); + throw ArgumentError("Exponent must not be negative: $exponent"); } if (exponent == 0) return one; @@ -1899,10 +1899,10 @@ class _BigIntImpl implements BigInt { final exponent = _ensureSystemBigInt(bigExponent, 'bigExponent'); final modulus = _ensureSystemBigInt(bigModulus, 'bigModulus'); if (exponent._isNegative) { - throw new ArgumentError("exponent must be positive: $exponent"); + throw ArgumentError("exponent must be positive: $exponent"); } if (modulus <= zero) { - throw new ArgumentError("modulus must be strictly positive: $modulus"); + throw ArgumentError("modulus must be strictly positive: $modulus"); } if (exponent._isZero) return one; @@ -1912,8 +1912,8 @@ class _BigIntImpl implements BigInt { if (cannotUseMontgomery || exponentBitlen < 64) { _BigIntReduction z = (cannotUseMontgomery || exponentBitlen < 8) - ? new _BigIntClassicReduction(modulus) - : new _BigIntMontgomeryReduction(modulus); + ? _BigIntClassicReduction(modulus) + : _BigIntMontgomeryReduction(modulus); var resultDigits = _newDigits(2 * z._normModulusUsed + 2); var result2Digits = _newDigits(2 * z._normModulusUsed + 2); var gDigits = _newDigits(z._normModulusUsed); @@ -1958,12 +1958,12 @@ class _BigIntImpl implements BigInt { k = 5; else k = 6; - _BigIntReduction z = new _BigIntMontgomeryReduction(modulus); + _BigIntReduction z = _BigIntMontgomeryReduction(modulus); var n = 3; final int k1 = k - 1; final km = (1 << k) - 1; - List gDigits = new List.filled(km + 1, null); - List gUsed = new List.filled(km + 1, null); + List gDigits = List.filled(km + 1, null); + List gUsed = List.filled(km + 1, null); gDigits[1] = _newDigits(z._normModulusUsed); gUsed[1] = z._convert(this, gDigits[1]); if (k > 1) { @@ -2076,14 +2076,14 @@ class _BigIntImpl implements BigInt { if (inv) { if ((yUsed == 1) && (yDigits[0] == 1)) return one; if ((yUsed == 0) || (yDigits[0].isEven && xDigits[0].isEven)) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } } else { if (x._isZero) { - throw new ArgumentError.value(0, "this", "must not be zero"); + throw ArgumentError.value(0, "this", "must not be zero"); } if (y._isZero) { - throw new ArgumentError.value(0, "other", "must not be zero"); + throw ArgumentError.value(0, "other", "must not be zero"); } if (((xUsed == 1) && (xDigits[0] == 1)) || ((yUsed == 1) && (yDigits[0] == 1))) @@ -2284,13 +2284,13 @@ class _BigIntImpl implements BigInt { if (shiftAmount > 0) { maxUsed = _lShiftDigits(vDigits, maxUsed, shiftAmount, vDigits); } - return new _BigIntImpl._(false, maxUsed, vDigits); + return _BigIntImpl._(false, maxUsed, vDigits); } // No inverse if v != 1. var i = maxUsed - 1; while ((i > 0) && (vDigits[i] == 0)) --i; if ((i != 0) || (vDigits[0] != 1)) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } if (dIsNegative) { @@ -2309,7 +2309,7 @@ class _BigIntImpl implements BigInt { _absSub(dDigits, abcdUsed, xDigits, maxUsed, dDigits); } } - return new _BigIntImpl._(false, maxUsed, dDigits); + return _BigIntImpl._(false, maxUsed, dDigits); } /** @@ -2324,7 +2324,7 @@ class _BigIntImpl implements BigInt { _BigIntImpl modInverse(BigInt bigInt) { final modulus = _ensureSystemBigInt(bigInt, 'bigInt'); if (modulus <= zero) { - throw new ArgumentError("Modulus must be strictly positive: $modulus"); + throw ArgumentError("Modulus must be strictly positive: $modulus"); } if (modulus == one) return zero; var tmp = this; @@ -2464,7 +2464,7 @@ class _BigIntImpl implements BigInt { if (_isZero) return 0.0; // We fill the 53 bits little-endian. - var resultBits = new Uint8List(8); + var resultBits = Uint8List(8); var length = _digitBits * (_used - 1) + _digits[_used - 1].bitLength; if (length > maxDoubleExponent + 53) { @@ -2611,7 +2611,7 @@ class _BigIntImpl implements BigInt { * The [radix] argument must be an integer in the range 2 to 36. */ String toRadixString(int radix) { - if (radix < 2 || radix > 36) throw new RangeError.range(radix, 2, 36); + if (radix < 2 || radix > 36) throw RangeError.range(radix, 2, 36); if (_used == 0) return "0"; @@ -2623,7 +2623,7 @@ class _BigIntImpl implements BigInt { if (radix == 16) return _toHexString(); - var base = new _BigIntImpl._fromInt(radix); + var base = _BigIntImpl._fromInt(radix); var reversedDigitCodeUnits = []; var rest = this.abs(); while (!rest._isZero) { @@ -2631,7 +2631,7 @@ class _BigIntImpl implements BigInt { rest = rest ~/ base; reversedDigitCodeUnits.add(_toRadixCodeUnit(digit)); } - var digitString = new String.fromCharCodes(reversedDigitCodeUnits.reversed); + var digitString = String.fromCharCodes(reversedDigitCodeUnits.reversed); if (_isNegative) return "-" + digitString; return digitString; } @@ -2654,7 +2654,7 @@ class _BigIntImpl implements BigInt { const _dash = 45; chars.add(_dash); } - return new String.fromCharCodes(chars.reversed); + return String.fromCharCodes(chars.reversed); } static _BigIntImpl _ensureSystemBigInt(BigInt bigInt, String parameterName) { @@ -2829,7 +2829,7 @@ class _BigIntMontgomeryReduction implements _BigIntReduction { resultDigits[i] = xDigits[i]; } var resultUsed = _reduce(resultDigits, xUsed); - return new _BigIntImpl._(false, resultUsed, resultDigits); + return _BigIntImpl._(false, resultUsed, resultDigits); } // x = x/R mod _modulus. @@ -3002,7 +3002,7 @@ class _BigIntClassicReduction implements _BigIntReduction { } _BigIntImpl _revert(Uint32List xDigits, int xUsed) { - return new _BigIntImpl._(false, xUsed, xDigits); + return _BigIntImpl._(false, xUsed, xDigits); } int _reduce(Uint32List xDigits, int xUsed) { diff --git a/sdk/lib/_internal/vm_shared/lib/collection_patch.dart b/sdk/lib/_internal/vm_shared/lib/collection_patch.dart index d14297a77b6..75385a69f53 100644 --- a/sdk/lib/_internal/vm_shared/lib/collection_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/collection_patch.dart @@ -18,13 +18,13 @@ class HashMap { if (isValidKey == null) { if (hashCode == null) { if (equals == null) { - return new _HashMap(); + return _HashMap(); } hashCode = _defaultHashCode; } else { if (identical(identityHashCode, hashCode) && identical(identical, equals)) { - return new _IdentityHashMap(); + return _IdentityHashMap(); } equals ??= _defaultEquals; } @@ -32,11 +32,11 @@ class HashMap { hashCode ??= _defaultHashCode; equals ??= _defaultEquals; } - return new _CustomHashMap(equals, hashCode, isValidKey); + return _CustomHashMap(equals, hashCode, isValidKey); } @patch - factory HashMap.identity() => new _IdentityHashMap(); + factory HashMap.identity() => _IdentityHashMap(); Set _newKeySet(); } @@ -54,8 +54,8 @@ base class _HashMap extends MapBase implements HashMap { bool get isEmpty => _elementCount == 0; bool get isNotEmpty => _elementCount != 0; - Iterable get keys => new _HashMapKeyIterable(this); - Iterable get values => new _HashMapValueIterable(this); + Iterable get keys => _HashMapKeyIterable(this); + Iterable get values => _HashMapValueIterable(this); bool containsKey(Object? key) { final hashCode = key.hashCode; @@ -149,7 +149,7 @@ base class _HashMap extends MapBase implements HashMap { while (entry != null) { action(unsafeCast(entry.key), unsafeCast(entry.value)); if (stamp != _modificationCount) { - throw new ConcurrentModificationError(this); + throw ConcurrentModificationError(this); } entry = entry.next; } @@ -178,7 +178,7 @@ base class _HashMap extends MapBase implements HashMap { } void clear() { - _buckets = new List.filled(_INITIAL_CAPACITY, null); + _buckets = List.filled(_INITIAL_CAPACITY, null); if (_elementCount > 0) { _elementCount = 0; _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK; @@ -205,7 +205,7 @@ base class _HashMap extends MapBase implements HashMap { V value, int hashCode, ) { - final entry = new _HashMapEntry(key, value, hashCode, buckets[index]); + final entry = _HashMapEntry(key, value, hashCode, buckets[index]); buckets[index] = entry; final newElements = _elementCount + 1; _elementCount = newElements; @@ -219,7 +219,7 @@ base class _HashMap extends MapBase implements HashMap { final oldBuckets = _buckets; final oldLength = oldBuckets.length; final newLength = oldLength << 1; - final newBuckets = new List<_HashMapEntry?>.filled(newLength, null); + final newBuckets = List<_HashMapEntry?>.filled(newLength, null); for (int i = 0; i < oldLength; i++) { var entry = oldBuckets[i]; while (entry != null) { @@ -256,7 +256,7 @@ base class _HashMap extends MapBase implements HashMap { } } - Set _newKeySet() => new _HashSet(); + Set _newKeySet() => _HashSet(); } base class _CustomHashMap extends _HashMap { @@ -364,7 +364,7 @@ base class _CustomHashMap extends _HashMap { return null; } - Set _newKeySet() => new _CustomHashSet(_equals, _hashCode, _validKey); + Set _newKeySet() => _CustomHashSet(_equals, _hashCode, _validKey); } base class _IdentityHashMap extends _HashMap { @@ -475,7 +475,7 @@ base class _IdentityHashMap extends _HashMap { } } - Set _newKeySet() => new _IdentityHashSet(); + Set _newKeySet() => _IdentityHashSet(); } class _HashMapEntry { @@ -497,7 +497,7 @@ abstract class _HashMapIterable class _HashMapKeyIterable extends _HashMapIterable { _HashMapKeyIterable(_HashMap map) : super(map); - Iterator get iterator => new _HashMapKeyIterator(_map); + Iterator get iterator => _HashMapKeyIterator(_map); bool contains(Object? key) => _map.containsKey(key); void forEach(void action(K key)) { _map.forEach((K key, _) { @@ -510,7 +510,7 @@ class _HashMapKeyIterable extends _HashMapIterable { class _HashMapValueIterable extends _HashMapIterable { _HashMapValueIterable(_HashMap map) : super(map); - Iterator get iterator => new _HashMapValueIterator(_map); + Iterator get iterator => _HashMapValueIterator(_map); bool contains(Object? value) => _map.containsValue(value); void forEach(void action(V value)) { _map.forEach((_, V value) { @@ -530,7 +530,7 @@ abstract class _HashMapIterator implements Iterator { bool moveNext() { if (_stamp != _map._modificationCount) { - throw new ConcurrentModificationError(_map); + throw ConcurrentModificationError(_map); } var entry = _entry; if (entry != null) { @@ -577,13 +577,13 @@ class HashSet { if (isValidKey == null) { if (hashCode == null) { if (equals == null) { - return new _HashSet(); + return _HashSet(); } hashCode = _defaultHashCode; } else { if (identical(identityHashCode, hashCode) && identical(identical, equals)) { - return new _IdentityHashSet(); + return _IdentityHashSet(); } equals ??= _defaultEquals; } @@ -591,11 +591,11 @@ class HashSet { hashCode ??= _defaultHashCode; equals ??= _defaultEquals; } - return new _CustomHashSet(equals, hashCode, isValidKey); + return _CustomHashSet(equals, hashCode, isValidKey); } @patch - factory HashSet.identity() => new _IdentityHashSet(); + factory HashSet.identity() => _IdentityHashSet(); } base class _HashSet extends _SetBase implements HashSet { @@ -608,11 +608,11 @@ base class _HashSet extends _SetBase implements HashSet { bool _equals(Object? e1, Object? e2) => e1 == e2; int _hashCode(Object? e) => e.hashCode; - static Set _newEmpty() => new _HashSet(); + static Set _newEmpty() => _HashSet(); // Iterable. - Iterator get iterator => new _HashSetIterator(this); + Iterator get iterator => _HashSetIterator(this); int get length => _elementCount; @@ -726,7 +726,7 @@ base class _HashSet extends _SetBase implements HashSet { int modificationCount = _modificationCount; bool testResult = test(entry.key); if (modificationCount != _modificationCount) { - throw new ConcurrentModificationError(this); + throw ConcurrentModificationError(this); } if (testResult == removeMatching) { final next = entry.remove(); @@ -764,7 +764,7 @@ base class _HashSet extends _SetBase implements HashSet { } void _addEntry(E key, int hashCode, int index) { - _buckets[index] = new _HashSetEntry(key, hashCode, _buckets[index]); + _buckets[index] = _HashSetEntry(key, hashCode, _buckets[index]); int newElements = _elementCount + 1; _elementCount = newElements; int length = _buckets.length; @@ -792,16 +792,16 @@ base class _HashSet extends _SetBase implements HashSet { _buckets = newBuckets; } - HashSet _newSet() => new _HashSet(); - HashSet _newSimilarSet() => new _HashSet(); + HashSet _newSet() => _HashSet(); + HashSet _newSimilarSet() => _HashSet(); } base class _IdentityHashSet extends _HashSet { int _hashCode(Object? e) => identityHashCode(e); bool _equals(Object? e1, Object? e2) => identical(e1, e2); - HashSet _newSet() => new _IdentityHashSet(); - HashSet _newSimilarSet() => new _IdentityHashSet(); + HashSet _newSet() => _IdentityHashSet(); + HashSet _newSimilarSet() => _IdentityHashSet(); } base class _CustomHashSet extends _HashSet { @@ -844,8 +844,8 @@ base class _CustomHashSet extends _HashSet { bool _equals(Object? e1, Object? e2) => _equality(e1 as E, e2 as E); int _hashCode(Object? e) => _hasher(e as E); - HashSet _newSet() => new _CustomHashSet(_equality, _hasher, _validKey); - HashSet _newSimilarSet() => new _HashSet(); + HashSet _newSet() => _CustomHashSet(_equality, _hasher, _validKey); + HashSet _newSimilarSet() => _HashSet(); } class _HashSetEntry { @@ -872,7 +872,7 @@ class _HashSetIterator implements Iterator { bool moveNext() { if (_modificationCount != _set._modificationCount) { - throw new ConcurrentModificationError(_set); + throw ConcurrentModificationError(_set); } var localNext = _next; if (localNext != null) { diff --git a/sdk/lib/_internal/vm_shared/lib/compact_hash.dart b/sdk/lib/_internal/vm_shared/lib/compact_hash.dart index 3a0e066d0b5..3c925986566 100644 --- a/sdk/lib/_internal/vm_shared/lib/compact_hash.dart +++ b/sdk/lib/_internal/vm_shared/lib/compact_hash.dart @@ -417,7 +417,7 @@ base class _ConstMap extends _HashVMImmutableBase _ImmutableLinkedHashMapMixin implements LinkedHashMap { factory _ConstMap._uninstantiable() { - throw new UnsupportedError("_ConstMap can only be allocated by the VM"); + throw UnsupportedError("_ConstMap can only be allocated by the VM"); } } @@ -441,7 +441,7 @@ mixin _ImmutableLinkedHashMapMixin final size = _roundUpToPowerOfTwo( max(_data.length, _HashBase._INITIAL_INDEX_SIZE), ); - final newIndex = new Uint32List(size); + final newIndex = Uint32List(size); final hashMask = _HashBase._indexSizeToHashMask(size); assert(_hashMask == hashMask); @@ -525,9 +525,9 @@ mixin _LinkedHashMapMixin on _HashBase, _EqualsAndHashCode { } assert(size & (size - 1) == 0); assert(_HashBase._UNUSED_PAIR == 0); - _index = new Uint32List(size); + _index = Uint32List(size); _hashMask = hashMask; - _data = new List.filled(size, null); + _data = List.filled(size, null); _usedData = 0; _deletedKeys = 0; if (oldData != null) { @@ -556,9 +556,9 @@ mixin _LinkedHashMapMixin on _HashBase, _EqualsAndHashCode { assert(size & (size - 1) == 0); assert(_HashBase._UNUSED_PAIR == 0); - _index = new Uint32List(size); + _index = Uint32List(size); _hashMask = hashMask; - _data = new List.filled(size, null); + _data = List.filled(size, null); _usedData = 0; _deletedKeys = 0; for (int i = 0; i < keyValuePairs.length; i += 2) { @@ -569,8 +569,7 @@ mixin _LinkedHashMapMixin on _HashBase, _EqualsAndHashCode { } void _regenerateIndex() { - _index = - _data.length == 0 ? _uninitializedIndex : new Uint32List(_data.length); + _index = _data.length == 0 ? _uninitializedIndex : Uint32List(_data.length); assert(_hashMask == _HashBase._UNINITIALIZED_HASH_MASK); _hashMask = _HashBase._indexSizeToHashMask(_index.length); final int tmpUsed = _usedData; @@ -1038,9 +1037,9 @@ mixin _LinkedHashSetMixin on _HashBase, _EqualsAndHashCode { size = _HashBase._INITIAL_INDEX_SIZE; hashMask = _HashBase._indexSizeToHashMask(size); } - _index = new Uint32List(size); + _index = Uint32List(size); _hashMask = hashMask; - _data = new List.filled(size >> 1, null); + _data = List.filled(size >> 1, null); _usedData = 0; _deletedKeys = 0; if (oldData != null) { @@ -1154,7 +1153,7 @@ mixin _LinkedHashSetMixin on _HashBase, _EqualsAndHashCode { final size = _roundUpToPowerOfTwo( max(_data.length, _HashBase._INITIAL_INDEX_SIZE), ); - _index = _data.length == 0 ? _uninitializedIndex : new Uint32List(size); + _index = _data.length == 0 ? _uninitializedIndex : Uint32List(size); assert(_hashMask == _HashBase._UNINITIALIZED_HASH_MASK); _hashMask = _HashBase._indexSizeToHashMask(_index.length); _rehash(); @@ -1208,7 +1207,7 @@ base class _ConstSet extends _HashVMImmutableBase _ImmutableLinkedHashSetMixin implements LinkedHashSet { factory _ConstSet._uninstantiable() { - throw new UnsupportedError("_ConstSet can only be allocated by the VM"); + throw UnsupportedError("_ConstSet can only be allocated by the VM"); } Set cast() => Set.castFrom(this, newSet: _newEmpty); @@ -1239,7 +1238,7 @@ mixin _ImmutableLinkedHashSetMixin final size = _roundUpToPowerOfTwo( max(_data.length * 2, _HashBase._INITIAL_INDEX_SIZE), ); - final index = new Uint32List(size); + final index = Uint32List(size); final hashMask = _HashBase._indexSizeToHashMask(size); assert(_hashMask == hashMask); diff --git a/sdk/lib/_internal/vm_shared/lib/integers_patch.dart b/sdk/lib/_internal/vm_shared/lib/integers_patch.dart index d7553385c6a..630fe91f144 100644 --- a/sdk/lib/_internal/vm_shared/lib/integers_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/integers_patch.dart @@ -48,7 +48,7 @@ class int { @patch static int parse(String source, {int? radix, int onError(String source)?}) { - if (source == null) throw new ArgumentError("The source must not be null"); + if (source == null) throw ArgumentError("The source must not be null"); if (source.isEmpty) { return _handleFormatError(onError, source, 0, radix, null) as int; } @@ -57,7 +57,7 @@ class int { int? result = _tryParseSmi(source, 0, source.length - 1); if (result != null) return result; } else if (radix < 2 || radix > 36) { - throw new RangeError("Radix $radix not in range 2..36"); + throw RangeError("Radix $radix not in range 2..36"); } // Split here so improve odds of parse being inlined and the checks omitted. return _parse(unsafeCast<_StringBase>(source), radix, onError) as int; @@ -106,14 +106,14 @@ class int { @patch static int? tryParse(String source, {int? radix}) { - if (source == null) throw new ArgumentError("The source must not be null"); + if (source == null) throw ArgumentError("The source must not be null"); if (source.isEmpty) return null; if (radix == null || radix == 10) { // Try parsing immediately, without trimming whitespace. int? result = _tryParseSmi(source, 0, source.length - 1); if (result != null) return result; } else if (radix < 2 || radix > 36) { - throw new RangeError("Radix $radix not in range 2..36"); + throw RangeError("Radix $radix not in range 2..36"); } return _parse(unsafeCast<_StringBase>(source), radix, _kNull); } @@ -129,12 +129,12 @@ class int { ) { if (onError != null) return onError(source); if (message != null) { - throw new FormatException(message, source, index); + throw FormatException(message, source, index); } if (radix == null) { - throw new FormatException("Invalid number", source, index); + throw FormatException("Invalid number", source, index); } - throw new FormatException("Invalid radix-$radix number", source, index); + throw FormatException("Invalid radix-$radix number", source, index); } static int? _parseRadix( @@ -254,7 +254,7 @@ class int { // For each radix, 2-36, how many digits are guaranteed to fit in a smi, // and magnitude of such a block (radix ** digit-count). // 32-bit limit/multiplier at (radix - 2)*4, 64-bit limit at (radix-2)*4+2 - static const _PARSE_LIMITS = const [ + static const _PARSE_LIMITS = [ 30, 1073741824, 62, 4611686018427387904, // radix: 2 18, 387420489, 39, 4052555153018976267, 15, 1073741824, 30, 1152921504606846976, @@ -295,11 +295,8 @@ class int { static const _maxInt64 = 0x7fffffffffffffff; static const _minInt64 = -0x8000000000000000; - static const _int64UnsignedOverflowLimits = const [0xfffffffff, 0xf]; - static const _int64UnsignedSmiOverflowLimits = const [ - 0xfffffff, - 0xfffffffffffffff, - ]; + static const _int64UnsignedOverflowLimits = [0xfffffffff, 0xf]; + static const _int64UnsignedSmiOverflowLimits = [0xfffffff, 0xfffffffffffffff]; /// Calculation of the expression /// @@ -316,7 +313,7 @@ class int { /// * `[tableIndex*2 + 1]` = negative limit for result /// * `[tableIndex*2 + 2]` = limit for smi if result is exactly at positive limit /// * `[tableIndex*2 + 3]` = limit for smi if result is exactly at negative limit - static final Int64List _int64OverflowLimits = new Int64List( + static final Int64List _int64OverflowLimits = Int64List( _PARSE_LIMITS.length * 2, ); diff --git a/sdk/lib/_internal/vm_shared/lib/map_patch.dart b/sdk/lib/_internal/vm_shared/lib/map_patch.dart index 98ce4a599c1..e550bf4bab3 100644 --- a/sdk/lib/_internal/vm_shared/lib/map_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/map_patch.dart @@ -15,7 +15,7 @@ class Map { // The values are at position 2*n+1 and are not yet type checked. @pragma("vm:entry-point", "call") factory Map._fromLiteral(List elements) { - var map = new LinkedHashMap(); + var map = LinkedHashMap(); var len = elements.length; for (int i = 1; i < len; i += 2) { map[elements[i - 1]] = elements[i]; @@ -25,11 +25,11 @@ class Map { @patch factory Map.unmodifiable(Map other) { - return new UnmodifiableMapView(new Map.from(other)); + return UnmodifiableMapView(Map.from(other)); } @patch - factory Map() => new LinkedHashMap(); + factory Map() => LinkedHashMap(); } // Used by Dart_MapContainsKey. diff --git a/sdk/lib/_internal/vm_shared/lib/string_buffer_patch.dart b/sdk/lib/_internal/vm_shared/lib/string_buffer_patch.dart index d93e6e9630a..c4ec5a8bb81 100644 --- a/sdk/lib/_internal/vm_shared/lib/string_buffer_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/string_buffer_patch.dart @@ -77,7 +77,7 @@ class StringBuffer { void writeCharCode(int charCode) { if (charCode <= 0xFFFF) { if (charCode < 0) { - throw new RangeError.range(charCode, 0, 0x10FFFF); + throw RangeError.range(charCode, 0, 0x10FFFF); } _ensureCapacity(1); final localBuffer = _buffer!; @@ -85,7 +85,7 @@ class StringBuffer { _bufferCodeUnitMagnitude |= charCode; } else { if (charCode > 0x10FFFF) { - throw new RangeError.range(charCode, 0, 0x10FFFF); + throw RangeError.range(charCode, 0, 0x10FFFF); } _ensureCapacity(2); int bits = charCode - 0x10000; @@ -140,7 +140,7 @@ class StringBuffer { void _ensureCapacity(int n) { final localBuffer = _buffer; if (localBuffer == null) { - _buffer = new Uint16List(_BUFFER_SIZE); + _buffer = Uint16List(_BUFFER_SIZE); } else if (_bufferPosition + n > localBuffer.length) { _consumeBuffer(); } @@ -171,7 +171,7 @@ class StringBuffer { if (localParts == null) { // Empirically this is a good capacity to minimize total bytes allocated. - _parts = new _GrowableList.withCapacity(10)..add(str); + _parts = _GrowableList.withCapacity(10)..add(str); } else { localParts.add(str); int partsSinceCompaction = localParts.length - _partsCompactionIndex; diff --git a/sdk/lib/_internal/wasm/lib/boxed_double.dart b/sdk/lib/_internal/wasm/lib/boxed_double.dart index 45ca84a5a66..a19bbcc66ac 100644 --- a/sdk/lib/_internal/wasm/lib/boxed_double.dart +++ b/sdk/lib/_internal/wasm/lib/boxed_double.dart @@ -294,7 +294,7 @@ final class BoxedDouble implements double { num clamp(num lowerLimit, num upperLimit) { if (lowerLimit.compareTo(upperLimit) > 0) { - throw new ArgumentError(lowerLimit); + throw ArgumentError(lowerLimit); } if (lowerLimit.isNaN) return lowerLimit; if (this.compareTo(lowerLimit) < 0) return lowerLimit; diff --git a/sdk/lib/_internal/wasm/lib/boxed_int.dart b/sdk/lib/_internal/wasm/lib/boxed_int.dart index 4e149fa9892..446949ba382 100644 --- a/sdk/lib/_internal/wasm/lib/boxed_int.dart +++ b/sdk/lib/_internal/wasm/lib/boxed_int.dart @@ -274,7 +274,7 @@ final class BoxedInt implements int { } // Generic case involving doubles, and invalid integer ranges. if (lowerLimit.compareTo(upperLimit) > 0) { - throw new ArgumentError(lowerLimit); + throw ArgumentError(lowerLimit); } if (lowerLimit.isNaN) return lowerLimit; // Note that we don't need to care for -0.0 for the lower limit. @@ -394,7 +394,7 @@ final class BoxedInt implements int { } while (u != 0); if (!inv) return v << s; if (v != 1) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } if (d < 0) { d += x; @@ -415,7 +415,7 @@ final class BoxedInt implements int { if (t.geU(m)) t %= m; if (t == 1) return 1; if ((t == 0) || (t.isEven && m.isEven)) { - throw new Exception("Not coprime"); + throw Exception("Not coprime"); } return _binaryGcd(m, t, true); } diff --git a/sdk/lib/_internal/wasm/lib/compact_hash.dart b/sdk/lib/_internal/wasm/lib/compact_hash.dart index d4dbfd452f5..7cebb0a4daf 100644 --- a/sdk/lib/_internal/wasm/lib/compact_hash.dart +++ b/sdk/lib/_internal/wasm/lib/compact_hash.dart @@ -103,7 +103,7 @@ mixin _UnmodifiableSetMixin implements LinkedHashSet { /// field type nullable. @pragma("wasm:entry-point") final WasmArray _uninitializedHashBaseIndex = - const WasmArray.literal([const WasmI32(0)]); + const WasmArray.literal([WasmI32(0)]); /// The object marking uninitialized [_HashFieldBase._data] fields. /// @@ -312,9 +312,7 @@ base class _ConstMap extends _HashFieldBase _ImmutableLinkedHashMapMixin implements LinkedHashMap { factory _ConstMap._uninstantiable() { - throw new UnsupportedError( - "_ConstMap can only be allocated by the compiler", - ); + throw UnsupportedError("_ConstMap can only be allocated by the compiler"); } } @@ -1125,9 +1123,7 @@ base class _ConstSet extends _HashFieldBase _ImmutableLinkedHashSetMixin implements LinkedHashSet { factory _ConstSet._uninstantiable() { - throw new UnsupportedError( - "_ConstSet can only be allocated by the compiler", - ); + throw UnsupportedError("_ConstSet can only be allocated by the compiler"); } Set cast() => Set.castFrom(this, newSet: _newEmpty); diff --git a/sdk/lib/_internal/wasm/lib/convert_patch.dart b/sdk/lib/_internal/wasm/lib/convert_patch.dart index cfec2cf77dc..42d3462c5f5 100644 --- a/sdk/lib/_internal/wasm/lib/convert_patch.dart +++ b/sdk/lib/_internal/wasm/lib/convert_patch.dart @@ -2607,7 +2607,7 @@ class _Utf8Decoder { // This table is the Wasm array version of `_Utf8Decoder.transitionTable`, // refer to the original type for documentation of the values. - static const _transitionTable = const ImmutableWasmArray.literal([ + static const _transitionTable = ImmutableWasmArray.literal([ 32, 0, 48, 58, 88, 69, 67, 67, 67, 67, 67, 78, 58, 108, 68, 98, 32, 0, // 48, 58, 88, 69, 67, 67, 67, 67, 67, 78, 118, 108, 68, 98, 32, 0, 48, 58, // 88, 69, 67, 67, 67, 67, 67, 78, 58, 108, 68, 98, 32, 65, 65, 65, 65, 65, // @@ -2620,7 +2620,7 @@ class _Utf8Decoder { // This table is the Wasm array version of `_Utf8Decoder.typeTable`, // refer to the original type for documentation of the values. - static const _typeTable = const ImmutableWasmArray.literal([ + static const _typeTable = ImmutableWasmArray.literal([ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, // diff --git a/sdk/lib/_internal/wasm/lib/errors_patch.dart b/sdk/lib/_internal/wasm/lib/errors_patch.dart index d6a7128d67b..9dc9d3362b7 100644 --- a/sdk/lib/_internal/wasm/lib/errors_patch.dart +++ b/sdk/lib/_internal/wasm/lib/errors_patch.dart @@ -274,7 +274,7 @@ class _DuplicatedFieldInitializerError extends Error { @patch class StateError { static _throwNew(String msg) { - throw new StateError(msg); + throw StateError(msg); } } diff --git a/sdk/lib/_internal/wasm/lib/int_patch.dart b/sdk/lib/_internal/wasm/lib/int_patch.dart index 38252bdbf06..8738c8995de 100644 --- a/sdk/lib/_internal/wasm/lib/int_patch.dart +++ b/sdk/lib/_internal/wasm/lib/int_patch.dart @@ -248,7 +248,7 @@ class int { } // For each radix, 2-36, how many digits are guaranteed to fit in an `int`. - static const _PARSE_LIMITS = const ImmutableWasmArray.literal([ + static const _PARSE_LIMITS = ImmutableWasmArray.literal([ 0, // unused 0, // unused 63, // radix: 2 diff --git a/sdk/lib/_internal/wasm/lib/io_patch.dart b/sdk/lib/_internal/wasm/lib/io_patch.dart index fd9fdf98271..ca4b6302345 100644 --- a/sdk/lib/_internal/wasm/lib/io_patch.dart +++ b/sdk/lib/_internal/wasm/lib/io_patch.dart @@ -12,42 +12,42 @@ import 'dart:typed_data'; class _Directory { @patch static _current(_Namespace namespace) { - throw new UnsupportedError("Directory._current"); + throw UnsupportedError("Directory._current"); } @patch static _setCurrent(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("Directory_SetCurrent"); + throw UnsupportedError("Directory_SetCurrent"); } @patch static _createTemp(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("Directory._createTemp"); + throw UnsupportedError("Directory._createTemp"); } @patch static String _systemTemp(_Namespace namespace) { - throw new UnsupportedError("Directory._systemTemp"); + throw UnsupportedError("Directory._systemTemp"); } @patch static _exists(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("Directory._exists"); + throw UnsupportedError("Directory._exists"); } @patch static _create(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("Directory._create"); + throw UnsupportedError("Directory._create"); } @patch static _deleteNative(_Namespace namespace, Uint8List path, bool recursive) { - throw new UnsupportedError("Directory._deleteNative"); + throw UnsupportedError("Directory._deleteNative"); } @patch static _rename(_Namespace namespace, Uint8List path, String newPath) { - throw new UnsupportedError("Directory._rename"); + throw UnsupportedError("Directory._rename"); } @patch @@ -58,7 +58,7 @@ class _Directory { bool recursive, bool followLinks, ) { - throw new UnsupportedError("Directory._fillWithDirectoryListing"); + throw UnsupportedError("Directory._fillWithDirectoryListing"); } } @@ -66,7 +66,7 @@ class _Directory { class _AsyncDirectoryListerOps { @patch factory _AsyncDirectoryListerOps(int pointer) { - throw new UnsupportedError("Directory._list"); + throw UnsupportedError("Directory._list"); } } @@ -74,7 +74,7 @@ class _AsyncDirectoryListerOps { class _EventHandler { @patch static void _sendData(Object? sender, SendPort sendPort, int data) { - throw new UnsupportedError("EventHandler._sendData"); + throw UnsupportedError("EventHandler._sendData"); } } @@ -82,7 +82,7 @@ class _EventHandler { class FileStat { @patch static _statSync(_Namespace namespace, String path) { - throw new UnsupportedError("FileStat.stat"); + throw UnsupportedError("FileStat.stat"); } } @@ -94,17 +94,17 @@ class FileSystemEntity { Uint8List path, bool followLinks, ) { - throw new UnsupportedError("FileSystemEntity._getType"); + throw UnsupportedError("FileSystemEntity._getType"); } @patch static _identicalNative(_Namespace namespace, String path1, String path2) { - throw new UnsupportedError("FileSystemEntity._identical"); + throw UnsupportedError("FileSystemEntity._identical"); } @patch static _resolveSymbolicLinks(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("FileSystemEntity._resolveSymbolicLinks"); + throw UnsupportedError("FileSystemEntity._resolveSymbolicLinks"); } } @@ -112,17 +112,17 @@ class FileSystemEntity { class _File { @patch static _exists(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._exists"); + throw UnsupportedError("File._exists"); } @patch static _create(_Namespace namespace, Uint8List path, bool exclusive) { - throw new UnsupportedError("File._create"); + throw UnsupportedError("File._create"); } @patch static _createLink(_Namespace namespace, Uint8List path, String target) { - throw new UnsupportedError("File._createLink"); + throw UnsupportedError("File._createLink"); } @patch @@ -132,67 +132,67 @@ class _File { @patch static _linkTarget(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._linkTarget"); + throw UnsupportedError("File._linkTarget"); } @patch static _deleteNative(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._deleteNative"); + throw UnsupportedError("File._deleteNative"); } @patch static _deleteLinkNative(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._deleteLinkNative"); + throw UnsupportedError("File._deleteLinkNative"); } @patch static _rename(_Namespace namespace, Uint8List oldPath, String newPath) { - throw new UnsupportedError("File._rename"); + throw UnsupportedError("File._rename"); } @patch static _renameLink(_Namespace namespace, Uint8List oldPath, String newPath) { - throw new UnsupportedError("File._renameLink"); + throw UnsupportedError("File._renameLink"); } @patch static _copy(_Namespace namespace, Uint8List oldPath, String newPath) { - throw new UnsupportedError("File._copy"); + throw UnsupportedError("File._copy"); } @patch static _lengthFromPath(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._lengthFromPath"); + throw UnsupportedError("File._lengthFromPath"); } @patch static _lastModified(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._lastModified"); + throw UnsupportedError("File._lastModified"); } @patch static _lastAccessed(_Namespace namespace, Uint8List path) { - throw new UnsupportedError("File._lastAccessed"); + throw UnsupportedError("File._lastAccessed"); } @patch static _setLastModified(_Namespace namespace, Uint8List path, int millis) { - throw new UnsupportedError("File._setLastModified"); + throw UnsupportedError("File._setLastModified"); } @patch static _setLastAccessed(_Namespace namespace, Uint8List path, int millis) { - throw new UnsupportedError("File._setLastAccessed"); + throw UnsupportedError("File._setLastAccessed"); } @patch static _open(_Namespace namespace, Uint8List path, int mode) { - throw new UnsupportedError("File._open"); + throw UnsupportedError("File._open"); } @patch static int _openStdio(int fd) { - throw new UnsupportedError("File._openStdio"); + throw UnsupportedError("File._openStdio"); } } @@ -200,17 +200,17 @@ class _File { class _Namespace { @patch static void _setupNamespace(var namespace) { - throw new UnsupportedError("_Namespace"); + throw UnsupportedError("_Namespace"); } @patch static _Namespace get _namespace { - throw new UnsupportedError("_Namespace"); + throw UnsupportedError("_Namespace"); } @patch static int get _namespacePointer { - throw new UnsupportedError("_Namespace"); + throw UnsupportedError("_Namespace"); } } @@ -218,7 +218,7 @@ class _Namespace { class _RandomAccessFileOps { @patch factory _RandomAccessFileOps(int pointer) { - throw new UnsupportedError("RandomAccessFile"); + throw UnsupportedError("RandomAccessFile"); } } @@ -226,7 +226,7 @@ class _RandomAccessFileOps { class _IOCrypto { @patch static Uint8List getRandomBytes(int count) { - throw new UnsupportedError("_IOCrypto.getRandomBytes"); + throw UnsupportedError("_IOCrypto.getRandomBytes"); } } @@ -234,67 +234,67 @@ class _IOCrypto { class _Platform { @patch static int _numberOfProcessors() { - throw new UnsupportedError("Platform._numberOfProcessors"); + throw UnsupportedError("Platform._numberOfProcessors"); } @patch static String _pathSeparator() { - throw new UnsupportedError("Platform._pathSeparator"); + throw UnsupportedError("Platform._pathSeparator"); } @patch static String _operatingSystem() { - throw new UnsupportedError("Platform._operatingSystem"); + throw UnsupportedError("Platform._operatingSystem"); } @patch static _operatingSystemVersion() { - throw new UnsupportedError("Platform._operatingSystemVersion"); + throw UnsupportedError("Platform._operatingSystemVersion"); } @patch static _localHostname() { - throw new UnsupportedError("Platform._localHostname"); + throw UnsupportedError("Platform._localHostname"); } @patch static _executable() { - throw new UnsupportedError("Platform._executable"); + throw UnsupportedError("Platform._executable"); } @patch static _resolvedExecutable() { - throw new UnsupportedError("Platform._resolvedExecutable"); + throw UnsupportedError("Platform._resolvedExecutable"); } @patch static List _executableArguments() { - throw new UnsupportedError("Platform._executableArguments"); + throw UnsupportedError("Platform._executableArguments"); } @patch static String _packageConfig() { - throw new UnsupportedError("Platform._packageConfig"); + throw UnsupportedError("Platform._packageConfig"); } @patch static _environment() { - throw new UnsupportedError("Platform._environment"); + throw UnsupportedError("Platform._environment"); } @patch static String _version() { - throw new UnsupportedError("Platform._version"); + throw UnsupportedError("Platform._version"); } @patch static String _localeName() { - throw new UnsupportedError("Platform._localeName"); + throw UnsupportedError("Platform._localeName"); } @patch static Uri _script() { - throw new UnsupportedError("Platform._script"); + throw UnsupportedError("Platform._script"); } } @@ -302,32 +302,32 @@ class _Platform { class _ProcessUtils { @patch static Never _exit(int status) { - throw new UnsupportedError("ProcessUtils._exit"); + throw UnsupportedError("ProcessUtils._exit"); } @patch static void _setExitCode(int status) { - throw new UnsupportedError("ProcessUtils._setExitCode"); + throw UnsupportedError("ProcessUtils._setExitCode"); } @patch static int _getExitCode() { - throw new UnsupportedError("ProcessUtils._getExitCode"); + throw UnsupportedError("ProcessUtils._getExitCode"); } @patch static void _sleep(int millis) { - throw new UnsupportedError("ProcessUtils._sleep"); + throw UnsupportedError("ProcessUtils._sleep"); } @patch static int _pid(Process? process) { - throw new UnsupportedError("ProcessUtils._pid"); + throw UnsupportedError("ProcessUtils._pid"); } @patch static Stream _watchSignal(ProcessSignal signal) { - throw new UnsupportedError("ProcessUtils._watchSignal"); + throw UnsupportedError("ProcessUtils._watchSignal"); } } @@ -335,12 +335,12 @@ class _ProcessUtils { class ProcessInfo { @patch static int get currentRss { - throw new UnsupportedError("ProcessInfo.currentRss"); + throw UnsupportedError("ProcessInfo.currentRss"); } @patch static int get maxRss { - throw new UnsupportedError("ProcessInfo.maxRss"); + throw UnsupportedError("ProcessInfo.maxRss"); } } @@ -356,7 +356,7 @@ class Process { bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal, }) { - throw new UnsupportedError("Process.start"); + throw UnsupportedError("Process.start"); } @patch @@ -370,7 +370,7 @@ class Process { Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding, }) { - throw new UnsupportedError("Process.run"); + throw UnsupportedError("Process.run"); } @patch @@ -384,12 +384,12 @@ class Process { Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding, }) { - throw new UnsupportedError("Process.runSync"); + throw UnsupportedError("Process.runSync"); } @patch static bool killPid(int pid, [ProcessSignal signal = ProcessSignal.sigterm]) { - throw new UnsupportedError("Process.killPid"); + throw UnsupportedError("Process.killPid"); } } @@ -397,27 +397,27 @@ class Process { class InternetAddress { @patch static InternetAddress get loopbackIPv4 { - throw new UnsupportedError("InternetAddress.loopbackIPv4"); + throw UnsupportedError("InternetAddress.loopbackIPv4"); } @patch static InternetAddress get loopbackIPv6 { - throw new UnsupportedError("InternetAddress.loopbackIPv6"); + throw UnsupportedError("InternetAddress.loopbackIPv6"); } @patch static InternetAddress get anyIPv4 { - throw new UnsupportedError("InternetAddress.anyIPv4"); + throw UnsupportedError("InternetAddress.anyIPv4"); } @patch static InternetAddress get anyIPv6 { - throw new UnsupportedError("InternetAddress.anyIPv6"); + throw UnsupportedError("InternetAddress.anyIPv6"); } @patch factory InternetAddress(String address, {InternetAddressType? type}) { - throw new UnsupportedError("InternetAddress"); + throw UnsupportedError("InternetAddress"); } @patch @@ -425,7 +425,7 @@ class InternetAddress { Uint8List rawAddress, { InternetAddressType? type, }) { - throw new UnsupportedError("InternetAddress.fromRawAddress"); + throw UnsupportedError("InternetAddress.fromRawAddress"); } @patch @@ -433,7 +433,7 @@ class InternetAddress { String host, { InternetAddressType type = InternetAddressType.any, }) { - throw new UnsupportedError("InternetAddress.lookup"); + throw UnsupportedError("InternetAddress.lookup"); } @patch @@ -441,7 +441,7 @@ class InternetAddress { InternetAddress address, String host, ) { - throw new UnsupportedError("InternetAddress._cloneWithNewHost"); + throw UnsupportedError("InternetAddress._cloneWithNewHost"); } @patch @@ -454,7 +454,7 @@ class InternetAddress { class NetworkInterface { @patch static bool get listSupported { - throw new UnsupportedError("NetworkInterface.listSupported"); + throw UnsupportedError("NetworkInterface.listSupported"); } @patch @@ -463,7 +463,7 @@ class NetworkInterface { bool includeLinkLocal = false, InternetAddressType type = InternetAddressType.any, }) { - throw new UnsupportedError("NetworkInterface.list"); + throw UnsupportedError("NetworkInterface.list"); } } @@ -477,7 +477,7 @@ class RawServerSocket { bool v6Only = false, bool shared = false, }) { - throw new UnsupportedError("RawServerSocket.bind"); + throw UnsupportedError("RawServerSocket.bind"); } } @@ -491,7 +491,7 @@ class ServerSocket { bool v6Only = false, bool shared = false, }) { - throw new UnsupportedError("ServerSocket.bind"); + throw UnsupportedError("ServerSocket.bind"); } } @@ -505,7 +505,7 @@ class RawSocket { int sourcePort = 0, Duration? timeout, }) { - throw new UnsupportedError("RawSocket constructor"); + throw UnsupportedError("RawSocket constructor"); } @patch @@ -515,7 +515,7 @@ class RawSocket { dynamic sourceAddress, int sourcePort = 0, }) { - throw new UnsupportedError("RawSocket constructor"); + throw UnsupportedError("RawSocket constructor"); } } @@ -529,7 +529,7 @@ class Socket { int sourcePort = 0, Duration? timeout, }) { - throw new UnsupportedError("Socket constructor"); + throw UnsupportedError("Socket constructor"); } @patch @@ -539,7 +539,7 @@ class Socket { dynamic sourceAddress, int sourcePort = 0, }) { - throw new UnsupportedError("Socket constructor"); + throw UnsupportedError("Socket constructor"); } } @@ -600,7 +600,7 @@ class ResourceHandle { class SecureSocket { @patch factory SecureSocket._(RawSecureSocket rawSocket) { - throw new UnsupportedError("SecureSocket constructor"); + throw UnsupportedError("SecureSocket constructor"); } } @@ -608,7 +608,7 @@ class SecureSocket { class RawSynchronousSocket { @patch static RawSynchronousSocket connectSync(dynamic host, int port) { - throw new UnsupportedError("RawSynchronousSocket.connectSync"); + throw UnsupportedError("RawSynchronousSocket.connectSync"); } } @@ -624,17 +624,17 @@ class RawSocketOption { class SecurityContext { @patch factory SecurityContext({bool withTrustedRoots = false}) { - throw new UnsupportedError("SecurityContext constructor"); + throw UnsupportedError("SecurityContext constructor"); } @patch static SecurityContext get defaultContext { - throw new UnsupportedError("default SecurityContext getter"); + throw UnsupportedError("default SecurityContext getter"); } @patch static bool get alpnSupported { - throw new UnsupportedError("SecurityContext alpnSupported getter"); + throw UnsupportedError("SecurityContext alpnSupported getter"); } } @@ -642,7 +642,7 @@ class SecurityContext { class X509Certificate { @patch factory X509Certificate._() { - throw new UnsupportedError("X509Certificate constructor"); + throw UnsupportedError("X509Certificate constructor"); } } @@ -656,7 +656,7 @@ class RawDatagramSocket { bool reusePort = false, int ttl = 1, }) { - throw new UnsupportedError("RawDatagramSocket.bind"); + throw UnsupportedError("RawDatagramSocket.bind"); } } @@ -664,7 +664,7 @@ class RawDatagramSocket { class _SecureFilter { @patch factory _SecureFilter._() { - throw new UnsupportedError("_SecureFilter._SecureFilter"); + throw UnsupportedError("_SecureFilter._SecureFilter"); } } @@ -672,22 +672,22 @@ class _SecureFilter { class _StdIOUtils { @patch static Stdin _getStdioInputStream(int fd) { - throw new UnsupportedError("StdIOUtils._getStdioInputStream"); + throw UnsupportedError("StdIOUtils._getStdioInputStream"); } @patch static _getStdioOutputStream(int fd) { - throw new UnsupportedError("StdIOUtils._getStdioOutputStream"); + throw UnsupportedError("StdIOUtils._getStdioOutputStream"); } @patch static int _socketType(Socket socket) { - throw new UnsupportedError("StdIOUtils._socketType"); + throw UnsupportedError("StdIOUtils._socketType"); } @patch static _getStdioHandleType(int fd) { - throw new UnsupportedError("StdIOUtils._getStdioHandleType"); + throw UnsupportedError("StdIOUtils._getStdioHandleType"); } } @@ -695,7 +695,7 @@ class _StdIOUtils { class _WindowsCodePageDecoder { @patch static String _decodeBytes(List bytes) { - throw new UnsupportedError("_WindowsCodePageDecoder._decodeBytes"); + throw UnsupportedError("_WindowsCodePageDecoder._decodeBytes"); } } @@ -703,7 +703,7 @@ class _WindowsCodePageDecoder { class _WindowsCodePageEncoder { @patch static List _encodeString(String string) { - throw new UnsupportedError("_WindowsCodePageEncoder._encodeString"); + throw UnsupportedError("_WindowsCodePageEncoder._encodeString"); } } @@ -719,7 +719,7 @@ class RawZLibFilter { List? dictionary, bool raw, ) { - throw new UnsupportedError("_newZLibDeflateFilter"); + throw UnsupportedError("_newZLibDeflateFilter"); } @patch @@ -729,7 +729,7 @@ class RawZLibFilter { List? dictionary, bool raw, ) { - throw new UnsupportedError("_newZLibInflateFilter"); + throw UnsupportedError("_newZLibInflateFilter"); } } @@ -737,17 +737,17 @@ class RawZLibFilter { class Stdin { @patch int readByteSync() { - throw new UnsupportedError("Stdin.readByteSync"); + throw UnsupportedError("Stdin.readByteSync"); } @patch bool get echoMode { - throw new UnsupportedError("Stdin.echoMode"); + throw UnsupportedError("Stdin.echoMode"); } @patch void set echoMode(bool enabled) { - throw new UnsupportedError("Stdin.echoMode"); + throw UnsupportedError("Stdin.echoMode"); } @patch @@ -762,17 +762,17 @@ class Stdin { @patch bool get lineMode { - throw new UnsupportedError("Stdin.lineMode"); + throw UnsupportedError("Stdin.lineMode"); } @patch void set lineMode(bool enabled) { - throw new UnsupportedError("Stdin.lineMode"); + throw UnsupportedError("Stdin.lineMode"); } @patch bool get supportsAnsiEscapes { - throw new UnsupportedError("Stdin.supportsAnsiEscapes"); + throw UnsupportedError("Stdin.supportsAnsiEscapes"); } } @@ -780,22 +780,22 @@ class Stdin { class Stdout { @patch bool _hasTerminal(int fd) { - throw new UnsupportedError("Stdout.hasTerminal"); + throw UnsupportedError("Stdout.hasTerminal"); } @patch int _terminalColumns(int fd) { - throw new UnsupportedError("Stdout.terminalColumns"); + throw UnsupportedError("Stdout.terminalColumns"); } @patch int _terminalLines(int fd) { - throw new UnsupportedError("Stdout.terminalLines"); + throw UnsupportedError("Stdout.terminalLines"); } @patch static bool _supportsAnsiEscapes(int fd) { - throw new UnsupportedError("Stdout.supportsAnsiEscapes"); + throw UnsupportedError("Stdout.supportsAnsiEscapes"); } } @@ -807,12 +807,12 @@ class _FileSystemWatcher { int events, bool recursive, ) { - throw new UnsupportedError("_FileSystemWatcher.watch"); + throw UnsupportedError("_FileSystemWatcher.watch"); } @patch static bool get isSupported { - throw new UnsupportedError("_FileSystemWatcher.isSupported"); + throw UnsupportedError("_FileSystemWatcher.isSupported"); } } @@ -820,6 +820,6 @@ class _FileSystemWatcher { class _IOService { @patch static Future _dispatch(int request, List data) { - throw new UnsupportedError("_IOService._dispatch"); + throw UnsupportedError("_IOService._dispatch"); } } diff --git a/sdk/lib/_internal/wasm/lib/math_patch.dart b/sdk/lib/_internal/wasm/lib/math_patch.dart index e285e1a853d..a646ef630eb 100644 --- a/sdk/lib/_internal/wasm/lib/math_patch.dart +++ b/sdk/lib/_internal/wasm/lib/math_patch.dart @@ -149,7 +149,7 @@ class Random { factory Random([int? seed]) { var state = _Random._setupSeed((seed == null) ? _Random._nextSeed() : seed); // Crank a couple of times to distribute the seed bits a bit further. - return new _Random._withState(state) + return _Random._withState(state) .._nextState() .._nextState() .._nextState() @@ -225,7 +225,7 @@ class _Random implements Random { static const _POW2_27_D = 1.0 * (1 << 27); // Use a singleton Random object to get a new seed if no seed was passed. - static final _prng = new _Random._withState(_initialSeed()); + static final _prng = _Random._withState(_initialSeed()); static int _setupSeed(int seed) => mix64(seed); diff --git a/sdk/lib/_internal/wasm/lib/object_patch.dart b/sdk/lib/_internal/wasm/lib/object_patch.dart index 3e91a9b0969..789a2cdb91b 100644 --- a/sdk/lib/_internal/wasm/lib/object_patch.dart +++ b/sdk/lib/_internal/wasm/lib/object_patch.dart @@ -11,7 +11,7 @@ class Object { external bool operator ==(Object other); // Random number generator used to generate identity hash codes. - static final _hashCodeRnd = new Random(); + static final _hashCodeRnd = Random(); static int _objectHashCode(Object obj) { var result = getIdentityHashField(obj); @@ -55,7 +55,7 @@ class Object { @patch @pragma("wasm:entry-point") dynamic noSuchMethod(Invocation invocation) { - throw new NoSuchMethodError.withInvocation(this, invocation); + throw NoSuchMethodError.withInvocation(this, invocation); } // Used for `null.toString` tear-offs. @@ -65,6 +65,6 @@ class Object { // Used for `null.noSuchMethod` tear-offs. @pragma("wasm:entry-point") static dynamic _nullNoSuchMethod(Invocation invocation) { - throw new NoSuchMethodError.withInvocation(null, invocation); + throw NoSuchMethodError.withInvocation(null, invocation); } } diff --git a/sdk/lib/_internal/wasm/lib/regexp_helper.dart b/sdk/lib/_internal/wasm/lib/regexp_helper.dart index c712522ea7b..81c061c2433 100644 --- a/sdk/lib/_internal/wasm/lib/regexp_helper.dart +++ b/sdk/lib/_internal/wasm/lib/regexp_helper.dart @@ -138,7 +138,7 @@ class JSSyntaxRegExp implements RegExp { RegExpMatch? firstMatch(String string) { JSNativeMatch? m = _nativeRegExp.exec(string.toJS); - return m == null ? null : new _MatchImplementation(this, m); + return m == null ? null : _MatchImplementation(this, m); } bool hasMatch(String string) { @@ -161,7 +161,7 @@ class JSSyntaxRegExp implements RegExp { JSNativeRegExp regexp = _nativeGlobalVersion; regexp.lastIndex = start.toJS; JSNativeMatch? match = regexp.exec(string); - return match == null ? null : new _MatchImplementation(this, match); + return match == null ? null : _MatchImplementation(this, match); } RegExpMatch? _execAnchored(String string, int start) { @@ -172,7 +172,7 @@ class JSSyntaxRegExp implements RegExp { // If the last capture group participated, the original regexp did not // match at the start position. if (match.pop() != null) return null; - return new _MatchImplementation(this, match); + return _MatchImplementation(this, match); } RegExpMatch? matchAsPrefix(String string, [int start = 0]) { @@ -246,7 +246,7 @@ class _AllMatchesIterable extends Iterable { _AllMatchesIterable(this._re, this._string, this._start); Iterator get iterator => - new _AllMatchesIterator(_re, _string, _start); + _AllMatchesIterator(_re, _string, _start); } class _AllMatchesIterator implements Iterator { diff --git a/sdk/lib/_internal/wasm/lib/simd.dart b/sdk/lib/_internal/wasm/lib/simd.dart index b5debe10698..fb361eb880a 100644 --- a/sdk/lib/_internal/wasm/lib/simd.dart +++ b/sdk/lib/_internal/wasm/lib/simd.dart @@ -110,7 +110,7 @@ final class NaiveUnmodifiableInt32x4List extends NaiveInt32x4List { @override void operator []=(int index, Int32x4 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } @override @@ -216,7 +216,7 @@ final class NaiveUnmodifiableFloat32x4List extends NaiveFloat32x4List { @override void operator []=(int index, Float32x4 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } @override @@ -316,7 +316,7 @@ final class NaiveUnmodifiableFloat64x2List extends NaiveFloat64x2List { @override void operator []=(int index, Float64x2 value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } @override diff --git a/sdk/lib/_internal/wasm/lib/symbol_patch.dart b/sdk/lib/_internal/wasm/lib/symbol_patch.dart index 15e4098829f..6cdd319f12c 100644 --- a/sdk/lib/_internal/wasm/lib/symbol_patch.dart +++ b/sdk/lib/_internal/wasm/lib/symbol_patch.dart @@ -30,7 +30,7 @@ class Symbol { // Class._constructor@xxx -> Class._constructor // _Class@xxx._constructor@xxx -> _Class._constructor // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2 - StringBuffer result = new StringBuffer(); + StringBuffer result = StringBuffer(); bool add_setter_suffix = false; var pos = 0; if (string.length >= 4 && string[3] == ':') { diff --git a/sdk/lib/_internal/wasm/lib/weak_patch.dart b/sdk/lib/_internal/wasm/lib/weak_patch.dart index 812a1c96591..d151a4cce6c 100644 --- a/sdk/lib/_internal/wasm/lib/weak_patch.dart +++ b/sdk/lib/_internal/wasm/lib/weak_patch.dart @@ -17,7 +17,7 @@ void _checkValidWeakTarget(Object object) { (object is Pointer) || (object is Struct) || (object is Union)) { - throw new ArgumentError.value( + throw ArgumentError.value( object, "A string, number, boolean, record, Pointer, Struct or Union " "can't be a weak target", diff --git a/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart b/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart index 39649528c04..72db016221c 100644 --- a/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart +++ b/sdk/lib/_internal/wasm_js_compatibility/lib/convert_patch.dart @@ -16,8 +16,8 @@ dynamic _parseJson( String source, Object? Function(Object? key, Object? value)? reviver, ) { - _JsonListener listener = new _JsonListener(reviver); - var parser = new _JsonStringParser(listener); + _JsonListener listener = _JsonListener(reviver); + var parser = _JsonStringParser(listener); parser.chunk = source; parser.chunkEnd = source.length; parser.parse(0); @@ -171,7 +171,7 @@ class _NumberBuffer { Uint8List list; int length = 0; _NumberBuffer(int initialCapacity) - : list = new Uint8List(_initialCapacity(initialCapacity)); + : list = Uint8List(_initialCapacity(initialCapacity)); int get capacity => list.length; @@ -194,13 +194,13 @@ class _NumberBuffer { void ensureCapacity(int newCapacity) { Uint8List list = this.list; if (newCapacity <= list.length) return; - Uint8List newList = new Uint8List(newCapacity); + Uint8List newList = Uint8List(newCapacity); newList.setRange(0, list.length, list, 0); this.list = newList; } String getString() { - String result = new String.fromCharCodes(list, 0, length); + String result = String.fromCharCodes(list, 0, length); return result; } @@ -1128,7 +1128,7 @@ abstract class _ChunkedJsonParser { int beginChunkNumber(int state, int start) { int end = chunkEnd; int length = end - start; - var buffer = new _NumberBuffer(length); + var buffer = _NumberBuffer(length); copyCharsToList(start, end, buffer.list, 0); buffer.length = length; this.buffer = buffer; @@ -1337,7 +1337,7 @@ abstract class _ChunkedJsonParser { message = "Unexpected character"; if (position == chunkEnd) message = "Unexpected end of input"; } - throw new FormatException(message, chunk, position); + throw FormatException(message, chunk, position); } } @@ -1357,7 +1357,7 @@ class _JsonStringParser extends _ChunkedJsonParser { } void beginString() { - this.buffer = new StringBuffer(); + this.buffer = StringBuffer(); } void addSliceToString(int start, int end) { @@ -1441,7 +1441,7 @@ class _JsonUtf8Parser extends _ChunkedJsonParser> { String getString(int start, int end, int bits) { const int maxAsciiChar = 0x7f; if (bits <= maxAsciiChar) { - return new String.fromCharCodes(chunk, start, end); + return String.fromCharCodes(chunk, start, end); } beginString(); if (start < end) addSliceToString(start, end); @@ -1450,7 +1450,7 @@ class _JsonUtf8Parser extends _ChunkedJsonParser> { } void beginString() { - this.buffer = new StringBuffer(); + this.buffer = StringBuffer(); } void addSliceToString(int start, int end) { diff --git a/sdk/lib/async/broadcast_stream_controller.dart b/sdk/lib/async/broadcast_stream_controller.dart index 4d5cfabd661..76c02058b6d 100644 --- a/sdk/lib/async/broadcast_stream_controller.dart +++ b/sdk/lib/async/broadcast_stream_controller.dart @@ -98,34 +98,34 @@ abstract class _BroadcastStreamController : _state = _STATE_INITIAL; void Function() get onPause { - throw new UnsupportedError( + throw UnsupportedError( "Broadcast stream controllers do not support pause callbacks", ); } void set onPause(void onPauseHandler()?) { - throw new UnsupportedError( + throw UnsupportedError( "Broadcast stream controllers do not support pause callbacks", ); } void Function() get onResume { - throw new UnsupportedError( + throw UnsupportedError( "Broadcast stream controllers do not support pause callbacks", ); } void set onResume(void onResumeHandler()?) { - throw new UnsupportedError( + throw UnsupportedError( "Broadcast stream controllers do not support pause callbacks", ); } // StreamController interface. - Stream get stream => new _BroadcastStream(this); + Stream get stream => _BroadcastStream(this); - StreamSink get sink => new _StreamSinkWrapper(this); + StreamSink get sink => _StreamSinkWrapper(this); bool get isClosed => (_state & _STATE_CLOSED) != 0; @@ -205,9 +205,9 @@ abstract class _BroadcastStreamController bool cancelOnError, ) { if (isClosed) { - return new _DoneStreamSubscription(onDone); + return _DoneStreamSubscription(onDone); } - var subscription = new _BroadcastSubscription( + var subscription = _BroadcastSubscription( this, onData, onError, @@ -246,10 +246,10 @@ abstract class _BroadcastStreamController Error _addEventError() { if (isClosed) { - return new StateError("Cannot add new events after calling close"); + return StateError("Cannot add new events after calling close"); } assert(_isAddingStream); - return new StateError("Cannot add new events while doing an addStream"); + return StateError("Cannot add new events while doing an addStream"); } void add(T data) { @@ -280,11 +280,7 @@ abstract class _BroadcastStreamController Future addStream(Stream stream, {bool? cancelOnError}) { if (!_mayAddEvent) throw _addEventError(); _state |= _STATE_ADDSTREAM; - var addStreamState = new _AddStreamState( - this, - stream, - cancelOnError ?? false, - ); + var addStreamState = _AddStreamState(this, stream, cancelOnError ?? false); _addStreamState = addStreamState; return addStreamState.addStreamFuture; } @@ -311,7 +307,7 @@ abstract class _BroadcastStreamController void action(_BufferingStreamSubscription subscription), ) { if (_isFiring) { - throw new StateError( + throw StateError( "Cannot fire new event. Controller is already firing an event", ); } @@ -373,7 +369,7 @@ class _SyncBroadcastStreamController extends _BroadcastStreamController _addEventError() { if (_isFiring) { - return new StateError( + return StateError( "Cannot fire new event. Controller is already firing an event", ); } @@ -429,7 +425,7 @@ class _AsyncBroadcastStreamController extends _BroadcastStreamController { subscription != null; subscription = subscription._next ) { - subscription._addPending(new _DelayedData(data)); + subscription._addPending(_DelayedData(data)); } } @@ -439,7 +435,7 @@ class _AsyncBroadcastStreamController extends _BroadcastStreamController { subscription != null; subscription = subscription._next ) { - subscription._addPending(new _DelayedError(error, stackTrace)); + subscription._addPending(_DelayedError(error, stackTrace)); } } @@ -481,12 +477,12 @@ class _AsBroadcastStreamController extends _SyncBroadcastStreamController } void _addPendingEvent(_DelayedEvent event) { - (_pending ??= new _PendingEvents()).add(event); + (_pending ??= _PendingEvents()).add(event); } void add(T data) { if (!isClosed && _isFiring) { - _addPendingEvent(new _DelayedData(data)); + _addPendingEvent(_DelayedData(data)); return; } super.add(data); @@ -497,7 +493,7 @@ class _AsBroadcastStreamController extends _SyncBroadcastStreamController if (!_mayAddEvent) throw _addEventError(); AsyncError(:error, :stackTrace) = _interceptUserError(error, stackTrace); if (!isClosed && _isFiring) { - _addPendingEvent(new _DelayedError(error, stackTrace)); + _addPendingEvent(_DelayedError(error, stackTrace)); return; } _addError(error, stackTrace); diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart index 7de71a02ca1..4d69a8d749e 100644 --- a/sdk/lib/async/future.dart +++ b/sdk/lib/async/future.dart @@ -41,7 +41,7 @@ abstract class FutureOr { // Private generative constructor, so that it is not subclassable, mixable, // or instantiable. FutureOr._() { - throw new UnsupportedError("FutureOr cannot be instantiated"); + throw UnsupportedError("FutureOr cannot be instantiated"); } } @@ -235,7 +235,7 @@ abstract interface class Future { static final _Future _nullFuture = nullFuture as _Future; /// A `Future` completed with `false`. - static final _Future _falseFuture = new _Future.zoneValue( + static final _Future _falseFuture = _Future.zoneValue( false, _rootZone, ); @@ -253,7 +253,7 @@ abstract interface class Future { /// If a non-future value is returned, the returned future is completed /// with that value. factory Future(FutureOr computation()) { - _Future result = new _Future(); + _Future result = _Future(); Timer.run(() { FutureOr computationResult; try { @@ -280,7 +280,7 @@ abstract interface class Future { /// If calling [computation] returns a non-future value, /// the returned future is completed with that value. factory Future.microtask(FutureOr computation()) { - _Future result = new _Future(); + _Future result = _Future(); scheduleMicrotask(() { FutureOr computationResult; try { @@ -348,7 +348,7 @@ abstract interface class Future { @pragma("vm:entry-point") @pragma("vm:prefer-inline") factory Future.value([FutureOr? value]) { - return new _Future.immediate(value == null ? value as T : value); + return _Future.immediate(value == null ? value as T : value); } /// Creates a future that completes with an error. @@ -410,7 +410,7 @@ abstract interface class Future { ); } _Future result = _Future(); - new Timer(duration, () { + Timer(duration, () { if (computation == null) { result._complete(null as T); } else { @@ -612,7 +612,7 @@ abstract interface class Future { /// } /// ``` static Future any(Iterable> futures) { - var completer = new Completer.sync(); + var completer = Completer.sync(); void onValue(T value) { if (!completer.isCompleted) completer.complete(value); } @@ -697,7 +697,7 @@ abstract interface class Future { /// // Outputs: 'Finished with 3' /// ``` static Future doWhile(FutureOr action()) { - _Future doneSignal = new _Future(); + _Future doneSignal = _Future(); late void Function(bool) nextIteration; // Bind this callback explicitly so that each iteration isn't bound in the // context of all the previous iterations' callbacks. @@ -1192,7 +1192,7 @@ abstract interface class Completer { /// completer.complete('completion value'); /// } /// ``` - factory Completer() => new _AsyncCompleter(); + factory Completer() => _AsyncCompleter(); /// Completes the future synchronously. /// @@ -1243,7 +1243,7 @@ abstract interface class Completer { /// foo(); // In this case, foo() runs after bar(). /// }); /// ``` - factory Completer.sync() => new _SyncCompleter(); + factory Completer.sync() => _SyncCompleter(); /// The future that is completed by this completer. /// diff --git a/sdk/lib/async/future_impl.dart b/sdk/lib/async/future_impl.dart index 5e4797c25c0..5c9cf61c5dc 100644 --- a/sdk/lib/async/future_impl.dart +++ b/sdk/lib/async/future_impl.dart @@ -73,14 +73,14 @@ AsyncError _interceptUserError(Object error, StackTrace? stackTrace) { abstract class _Completer implements Completer { @pragma("wasm:entry-point") @pragma("vm:entry-point") - final _Future future = new _Future(); + final _Future future = _Future(); // Overridden by either a synchronous or asynchronous implementation. void complete([FutureOr? value]); @pragma("wasm:entry-point") void completeError(Object error, [StackTrace? stackTrace]) { - if (!future._mayComplete) throw new StateError("Future already completed"); + if (!future._mayComplete) throw StateError("Future already completed"); _completeErrorObject(_interceptUserError(error, stackTrace)); } @@ -97,7 +97,7 @@ abstract class _Completer implements Completer { class _AsyncCompleter extends _Completer { @pragma("wasm:entry-point") void complete([FutureOr? value]) { - if (!future._mayComplete) throw new StateError("Future already completed"); + if (!future._mayComplete) throw StateError("Future already completed"); future._asyncComplete(value == null ? value as dynamic : value); } @@ -112,7 +112,7 @@ class _AsyncCompleter extends _Completer { @pragma("vm:entry-point") class _SyncCompleter extends _Completer { void complete([FutureOr? value]) { - if (!future._mayComplete) throw new StateError("Future already completed"); + if (!future._mayComplete) throw StateError("Future already completed"); future._complete(value == null ? value as dynamic : value); } @@ -411,8 +411,8 @@ class _Future implements Future { onError = _registerErrorHandler(onError, currentZone); } } - _Future result = new _Future(); - _addListener(new _FutureListener.then(result, f, onError)); + _Future result = _Future(); + _addListener(_FutureListener.then(result, f, onError)); return result; } @@ -421,8 +421,8 @@ class _Future implements Future { /// Used by the implementation of `await` to listen to a future. /// The system created listeners are not registered in the zone. Future _thenAwait(FutureOr f(T value), Function onError) { - _Future result = new _Future(); - _addListener(new _FutureListener.thenAwait(result, f, onError)); + _Future result = _Future(); + _addListener(_FutureListener.thenAwait(result, f, onError)); return result; } @@ -442,12 +442,12 @@ class _Future implements Future { } Future catchError(Function onError, {bool test(Object error)?}) { - _Future result = new _Future(); + _Future result = _Future(); if (!identical(result._zone, _rootZone)) { onError = _registerErrorHandler(onError, result._zone); if (test != null) test = result._zone.registerUnaryCallback(test); } - _addListener(new _FutureListener.catchError(result, onError, test)); + _addListener(_FutureListener.catchError(result, onError, test)); return result; } @@ -469,15 +469,15 @@ class _Future implements Future { } Future whenComplete(dynamic action()) { - _Future result = new _Future(); + _Future result = _Future(); if (!identical(result._zone, _rootZone)) { action = result._zone.registerCallback(action); } - _addListener(new _FutureListener.whenComplete(result, action)); + _addListener(_FutureListener.whenComplete(result, action)); return result; } - Stream asStream() => new Stream.fromFuture(this); + Stream asStream() => Stream.fromFuture(this); void _setPendingComplete() { assert(_mayComplete); // Aka. _stateIncomplete @@ -914,7 +914,7 @@ class _Future implements Future { if (hasError && identical(source._error.error, e)) { listenerValueOrError = source._error; } else { - listenerValueOrError = new AsyncError(e, s); + listenerValueOrError = AsyncError(e, s); } listenerHasError = true; return; @@ -950,7 +950,7 @@ class _Future implements Future { try { listenerValueOrError = listener.handleValue(sourceResult); } catch (e, s) { - listenerValueOrError = new AsyncError(e, s); + listenerValueOrError = AsyncError(e, s); listenerHasError = true; } } @@ -967,7 +967,7 @@ class _Future implements Future { if (identical(source._error.error, e)) { listenerValueOrError = source._error; } else { - listenerValueOrError = new AsyncError(e, s); + listenerValueOrError = AsyncError(e, s); } listenerHasError = true; } @@ -1033,15 +1033,15 @@ class _Future implements Future { @pragma("vm:entry-point") Future timeout(Duration timeLimit, {FutureOr onTimeout()?}) { - if (_isComplete) return new _Future.immediate(this); + if (_isComplete) return _Future.immediate(this); @pragma('vm:awaiter-link') - _Future _future = new _Future(); + _Future _future = _Future(); Timer timer; if (onTimeout == null) { - timer = new Timer(timeLimit, () { + timer = Timer(timeLimit, () { _future._completeErrorObject( AsyncError( - new TimeoutException("Future not completed", timeLimit), + TimeoutException("Future not completed", timeLimit), StackTrace.current, ), ); @@ -1052,7 +1052,7 @@ class _Future implements Future { onTimeout, ); - timer = new Timer(timeLimit, () { + timer = Timer(timeLimit, () { try { _future._complete(zone.run(onTimeoutHandler)); } catch (e, s) { diff --git a/sdk/lib/async/schedule_microtask.dart b/sdk/lib/async/schedule_microtask.dart index 4245d6cf510..25e7c03d24f 100644 --- a/sdk/lib/async/schedule_microtask.dart +++ b/sdk/lib/async/schedule_microtask.dart @@ -61,7 +61,7 @@ void _startMicrotaskLoop() { /// The microtask is called after all other currently scheduled /// microtasks, but as part of the current system event. void _scheduleAsyncCallback(_AsyncCallback callback) { - _AsyncCallbackEntry newEntry = new _AsyncCallbackEntry(callback); + _AsyncCallbackEntry newEntry = _AsyncCallbackEntry(callback); _AsyncCallbackEntry? lastCallback = _lastCallback; if (lastCallback == null) { _nextCallback = _lastCallback = newEntry; @@ -86,7 +86,7 @@ void _schedulePriorityAsyncCallback(_AsyncCallback callback) { _lastPriorityCallback = _lastCallback; return; } - _AsyncCallbackEntry entry = new _AsyncCallbackEntry(callback); + _AsyncCallbackEntry entry = _AsyncCallbackEntry(callback); _AsyncCallbackEntry? lastPriorityCallback = _lastPriorityCallback; if (lastPriorityCallback == null) { entry.next = _nextCallback; diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart index 265d71f7a13..4c5f5ee8451 100644 --- a/sdk/lib/async/stream.dart +++ b/sdk/lib/async/stream.dart @@ -241,7 +241,7 @@ abstract mixin class Stream { // Use the controller's buffering to fill in the value even before // the stream has a listener. For a single value, it's not worth it // to wait for a listener before doing the `then` on the future. - _StreamController controller = new _SyncStreamController( + _StreamController controller = _SyncStreamController( null, null, null, @@ -295,7 +295,7 @@ abstract mixin class Stream { /// // "Done" when stream completed. /// ``` factory Stream.fromFutures(Iterable> futures) { - _StreamController controller = new _SyncStreamController( + _StreamController controller = _SyncStreamController( null, null, null, @@ -511,7 +511,7 @@ abstract mixin class Stream { } var controller = _SyncStreamController(null, null, null, null); // Counts the time that the Stream was running (and not paused). - Stopwatch watch = new Stopwatch(); + Stopwatch watch = Stopwatch(); controller.onListen = () { int computationCount = 0; void sendEvent(_) { @@ -544,7 +544,7 @@ abstract mixin class Stream { ..onResume = () { Duration elapsed = watch.elapsed; watch.start(); - timer = new Timer(period - elapsed, () { + timer = Timer(period - elapsed, () { timer = Timer.periodic(period, sendEvent); sendEvent(null); }); @@ -595,7 +595,7 @@ abstract mixin class Stream { Stream source, EventSink mapSink(EventSink sink), ) { - return new _BoundSinkStream(source, mapSink); + return _BoundSinkStream(source, mapSink); } /// Adapts [source] to be a `Stream`. @@ -604,8 +604,7 @@ abstract mixin class Stream { /// must satisfy the requirements of both the new type and its original type. /// /// Data events created by the source stream must also be instances of [T]. - static Stream castFrom(Stream source) => - new CastStream(source); + static Stream castFrom(Stream source) => CastStream(source); /// Whether this stream is a broadcast stream. bool get isBroadcast => false; @@ -683,7 +682,7 @@ abstract mixin class Stream { void onListen(StreamSubscription subscription)?, void onCancel(StreamSubscription subscription)?, }) { - return new _AsBroadcastStream(this, onListen, onCancel); + return _AsBroadcastStream(this, onListen, onCancel); } /// Adds a subscription to this stream. @@ -750,7 +749,7 @@ abstract mixin class Stream { /// customStream.listen(print); // Outputs event values: 4,5,6. /// ``` Stream where(bool test(T event)) { - return new _WhereStream(this, test); + return _WhereStream(this, test); } /// Transforms each element of this stream into a new stream event. @@ -794,7 +793,7 @@ abstract mixin class Stream { /// // Square: 16 /// ``` Stream map(S convert(T event)) { - return new _MapStream(this, convert); + return _MapStream(this, convert); } /// Creates a new stream with each data event of this stream asynchronously @@ -969,7 +968,7 @@ abstract mixin class Stream { " as arguments.", ); } - return new _HandleErrorStream(this, callback, test); + return _HandleErrorStream(this, callback, test); } /// Transforms each element of this stream into a sequence of elements. @@ -990,7 +989,7 @@ abstract mixin class Stream { /// If a broadcast stream is listened to more than once, each subscription /// will individually call `convert` and expand the events. Stream expand(Iterable convert(T element)) { - return new _ExpandStream(this, convert); + return _ExpandStream(this, convert); } /// Pipes the events of this stream into [streamConsumer]. @@ -1065,7 +1064,7 @@ abstract mixin class Stream { /// print(result); // 28 /// ``` Future reduce(T combine(T previous, T element)) { - _Future result = new _Future(); + _Future result = _Future(); bool seenFirst = false; late T value; StreamSubscription subscription = this.listen( @@ -1119,7 +1118,7 @@ abstract mixin class Stream { /// print(result); // 38 /// ``` Future fold(S initialValue, S combine(S previous, T element)) { - _Future result = new _Future(); + _Future result = _Future(); S value = initialValue; StreamSubscription subscription = this.listen( null, @@ -1157,8 +1156,8 @@ abstract mixin class Stream { /// print(result); // 'Mars--Venus--Earth' /// ``` Future join([String separator = ""]) { - _Future result = new _Future(); - StringBuffer buffer = new StringBuffer(); + _Future result = _Future(); + StringBuffer buffer = StringBuffer(); bool first = true; StreamSubscription subscription = this.listen( null, @@ -1210,7 +1209,7 @@ abstract mixin class Stream { /// print(result); // true /// ``` Future contains(Object? needle) { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1238,7 +1237,7 @@ abstract mixin class Stream { /// the returned future completes with that error, /// and processing stops. Future forEach(void action(T element)) { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1279,7 +1278,7 @@ abstract mixin class Stream { /// print(result); // false /// ``` Future every(bool test(T element)) { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1321,7 +1320,7 @@ abstract mixin class Stream { /// print(result); // true /// ``` Future any(bool test(T element)) { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1352,7 +1351,7 @@ abstract mixin class Stream { /// This operation listens to this stream, and a non-broadcast stream cannot /// be reused after finding its length. Future get length { - _Future future = new _Future(); + _Future future = _Future(); int count = 0; this.listen( (_) { @@ -1380,7 +1379,7 @@ abstract mixin class Stream { /// This operation listens to this stream, and a non-broadcast stream cannot /// be reused after checking whether it is empty. Future get isEmpty { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1412,7 +1411,7 @@ abstract mixin class Stream { /// and processing stops. Future> toList() { List result = []; - _Future> future = new _Future>(); + _Future> future = _Future>(); this.listen( (T data) { result.add(data); @@ -1442,8 +1441,8 @@ abstract mixin class Stream { /// the returned future is completed with that error, /// and processing stops. Future> toSet() { - Set result = new Set(); - _Future> future = new _Future>(); + Set result = Set(); + _Future> future = _Future>(); this.listen( (T data) { result.add(data); @@ -1512,7 +1511,7 @@ abstract mixin class Stream { /// stream.forEach(print); // Outputs events: 0, ... 59. /// ``` Stream take(int count) { - return new _TakeStream(this, count); + return _TakeStream(this, count); } /// Forwards data events while [test] is successful. @@ -1543,7 +1542,7 @@ abstract mixin class Stream { /// stream.forEach(print); // Outputs events: 0, ..., 5. /// ``` Stream takeWhile(bool test(T element)) { - return new _TakeWhileStream(this, test); + return _TakeWhileStream(this, test); } /// Skips the first [count] data events from this stream. @@ -1567,7 +1566,7 @@ abstract mixin class Stream { /// stream.forEach(print); // Skips events 0, ..., 6. Outputs events: 7, ... /// ``` Stream skip(int count) { - return new _SkipStream(this, count); + return _SkipStream(this, count); } /// Skip data events from this stream while they are matched by [test]. @@ -1595,7 +1594,7 @@ abstract mixin class Stream { /// stream.forEach(print); // Outputs events: 5, ..., 9. /// ``` Stream skipWhile(bool test(T element)) { - return new _SkipWhileStream(this, test); + return _SkipWhileStream(this, test); } /// Skips data events if they are equal to the previous data event. @@ -1624,7 +1623,7 @@ abstract mixin class Stream { /// stream.forEach(print); // Outputs events: 2,6,8,12,8,2. /// ``` Stream distinct([bool equals(T previous, T next)?]) { - return new _DistinctStream(this, equals); + return _DistinctStream(this, equals); } /// The first element of this stream. @@ -1644,7 +1643,7 @@ abstract mixin class Stream { /// Except for the type of the error, this method is equivalent to /// `this.elementAt(0)`. Future get first { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1671,7 +1670,7 @@ abstract mixin class Stream { /// If this stream is empty (the done event is the first event), /// the returned future completes with an error. Future get last { - _Future future = new _Future(); + _Future future = _Future(); late T result; bool foundResult = false; listen( @@ -1704,7 +1703,7 @@ abstract mixin class Stream { /// If this [Stream] is empty or has more than one element, /// the returned future completes with an error. Future get single { - _Future future = new _Future(); + _Future future = _Future(); late T result; bool foundResult = false; StreamSubscription subscription = this.listen( @@ -1774,7 +1773,7 @@ abstract mixin class Stream { /// print(result); // -1 /// ``` Future firstWhere(bool test(T element), {T orElse()?}) { - _Future future = new _Future(); + _Future future = _Future(); StreamSubscription subscription = this.listen( null, onError: future._completeError, @@ -1827,7 +1826,7 @@ abstract mixin class Stream { /// print(result); // -1 /// ``` Future lastWhere(bool test(T element), {T orElse()?}) { - _Future future = new _Future(); + _Future future = _Future(); late T result; bool foundResult = false; StreamSubscription subscription = this.listen( @@ -1894,7 +1893,7 @@ abstract mixin class Stream { /// // Throws. /// ``` Future singleWhere(bool test(T element), {T orElse()?}) { - _Future future = new _Future(); + _Future future = _Future(); late T result; bool foundResult = false; StreamSubscription subscription = this.listen( @@ -1951,7 +1950,7 @@ abstract mixin class Stream { /// with a [RangeError]. Future elementAt(int index) { RangeError.checkNotNegative(index, "index"); - _Future result = new _Future(); + _Future result = _Future(); int elementIndex = 0; StreamSubscription subscription; subscription = this.listen( @@ -1959,7 +1958,7 @@ abstract mixin class Stream { onError: result._completeError, onDone: () { result._completeError( - new IndexError.withLength( + IndexError.withLength( index, elementIndex, indexable: this, @@ -2035,9 +2034,9 @@ abstract mixin class Stream { Stream timeout(Duration timeLimit, {void onTimeout(EventSink sink)?}) { _StreamControllerBase controller; if (isBroadcast) { - controller = new _SyncBroadcastStreamController(null, null); + controller = _SyncBroadcastStreamController(null, null); } else { - controller = new _SyncStreamController(null, null, null, null); + controller = _SyncStreamController(null, null, null, null); } Zone zone = Zone.current; @@ -2046,7 +2045,7 @@ abstract mixin class Stream { if (onTimeout == null) { timeoutCallback = () { controller.addError( - new TimeoutException("No stream event", timeLimit), + TimeoutException("No stream event", timeLimit), null, ); }; @@ -2054,7 +2053,7 @@ abstract mixin class Stream { var registeredOnTimeout = zone.registerUnaryCallback>( onTimeout, ); - var wrapper = new _ControllerEventSinkWrapper(null); + var wrapper = _ControllerEventSinkWrapper(null); timeoutCallback = () { wrapper._sink = controller; // Only valid during call. zone.runUnaryGuarded(registeredOnTimeout, wrapper); @@ -2626,7 +2625,7 @@ abstract interface class StreamTransformer { static StreamTransformer castFrom( StreamTransformer source, ) { - return new CastStreamTransformer(source); + return CastStreamTransformer(source); } /// Transforms the provided [stream]. @@ -2692,7 +2691,7 @@ abstract interface class StreamIterator { factory StreamIterator(Stream stream) => // TODO(lrn): use redirecting factory constructor when type // arguments are supported. - new _StreamIterator(stream); + _StreamIterator(stream); /// Wait for the next stream value to be available. /// diff --git a/sdk/lib/async/stream_transformers.dart b/sdk/lib/async/stream_transformers.dart index 407f50b0b9e..491ddc0539d 100644 --- a/sdk/lib/async/stream_transformers.dart +++ b/sdk/lib/async/stream_transformers.dart @@ -74,7 +74,7 @@ class _SinkTransformerStreamSubscription /// error. void _addError(Object error, StackTrace stackTrace) { if (_isClosed) { - throw new StateError("Stream is already closed"); + throw StateError("Stream is already closed"); } super._addError(error, stackTrace); } @@ -86,7 +86,7 @@ class _SinkTransformerStreamSubscription /// error. void _close() { if (_isClosed) { - throw new StateError("Stream is already closed"); + throw StateError("Stream is already closed"); } super._close(); } @@ -153,7 +153,7 @@ class _StreamSinkTransformer extends StreamTransformerBase { const _StreamSinkTransformer(this._sinkMapper); Stream bind(Stream stream) => - new _BoundSinkStream(stream, _sinkMapper); + _BoundSinkStream(stream, _sinkMapper); } /// The result of binding a [StreamTransformer] for [Sink]-mappers. @@ -269,7 +269,7 @@ class _StreamHandlerTransformer extends _StreamSinkTransformer { void handleError(Object error, StackTrace stackTrace, EventSink sink)?, void handleDone(EventSink sink)?, }) : super((EventSink outputSink) { - return new _HandlerEventSink( + return _HandlerEventSink( handleData, handleError, handleDone, @@ -312,7 +312,7 @@ class _StreamSubscriptionTransformer extends StreamTransformerBase { const _StreamSubscriptionTransformer(this._onListen); Stream bind(Stream stream) => - new _BoundSubscriptionStream(stream, _onListen); + _BoundSubscriptionStream(stream, _onListen); } /// A stream transformed by a [_StreamSubscriptionTransformer]. diff --git a/sdk/lib/async/timer.dart b/sdk/lib/async/timer.dart index 5ff3711fb1c..242182a8aec 100644 --- a/sdk/lib/async/timer.dart +++ b/sdk/lib/async/timer.dart @@ -104,7 +104,7 @@ abstract interface class Timer { /// Timer.run(() => print('timer run')); /// ``` static void run(void Function() callback) { - new Timer(Duration.zero, callback); + Timer(Duration.zero, callback); } /// Cancels the timer. diff --git a/sdk/lib/core/stacktrace.dart b/sdk/lib/core/stacktrace.dart index a4cd0375857..b2f8688e916 100644 --- a/sdk/lib/core/stacktrace.dart +++ b/sdk/lib/core/stacktrace.dart @@ -16,7 +16,7 @@ abstract interface class StackTrace { /// /// This stack trace is used as the default in situations where /// a stack trace is required, but the user has not supplied one. - static const empty = const _StringStackTrace(""); + static const empty = _StringStackTrace(""); StackTrace(); // In case existing classes extend StackTrace. diff --git a/sdk/lib/internal/async_cast.dart b/sdk/lib/internal/async_cast.dart index bd5ccd56f17..3ecabaafca6 100644 --- a/sdk/lib/internal/async_cast.dart +++ b/sdk/lib/internal/async_cast.dart @@ -17,14 +17,14 @@ class CastStream extends Stream { void Function()? onDone, bool? cancelOnError, }) { - return new CastStreamSubscription( + return CastStreamSubscription( _source.listen(null, onDone: onDone, cancelOnError: cancelOnError), ) ..onData(onData) ..onError(onError); } - Stream cast() => new CastStream(_source); + Stream cast() => CastStream(_source); } class CastStreamSubscription implements StreamSubscription { @@ -115,7 +115,7 @@ class CastStreamTransformer CastStreamTransformer(this._source); StreamTransformer cast() => - new CastStreamTransformer(_source); + CastStreamTransformer(_source); Stream bind(Stream stream) => _source.bind(stream.cast()).cast(); } @@ -131,6 +131,5 @@ class CastConverter extends Converter { Stream bind(Stream stream) => _source.bind(stream.cast()).cast(); - Converter cast() => - new CastConverter(_source); + Converter cast() => CastConverter(_source); } diff --git a/sdk/lib/internal/cast.dart b/sdk/lib/internal/cast.dart index 61436ccf263..8de023fbf5b 100644 --- a/sdk/lib/internal/cast.dart +++ b/sdk/lib/internal/cast.dart @@ -9,7 +9,7 @@ part of dart._internal; abstract class _CastIterableBase extends Iterable { Iterable get _source; - Iterator get iterator => new CastIterator(_source.iterator); + Iterator get iterator => CastIterator(_source.iterator); // The following members use the default implementation on the // throwing iterator. These are all operations that have no more efficient @@ -36,8 +36,8 @@ abstract class _CastIterableBase extends Iterable { bool get isEmpty => _source.isEmpty; bool get isNotEmpty => _source.isNotEmpty; - Iterable skip(int count) => new CastIterable(_source.skip(count)); - Iterable take(int count) => new CastIterable(_source.take(count)); + Iterable skip(int count) => CastIterable(_source.skip(count)); + Iterable take(int count) => CastIterable(_source.take(count)); T elementAt(int index) => _source.elementAt(index) as T; T get first => _source.first as T; @@ -72,12 +72,12 @@ class CastIterable extends _CastIterableBase { factory CastIterable(Iterable source) { if (source is EfficientLengthIterable) { - return new _EfficientLengthCastIterable(source); + return _EfficientLengthCastIterable(source); } - return new CastIterable._(source); + return CastIterable._(source); } - Iterable cast() => new CastIterable(_source); + Iterable cast() => CastIterable(_source); } class _EfficientLengthCastIterable extends CastIterable @@ -114,7 +114,7 @@ abstract class _CastListBase extends _CastIterableBase } void addAll(Iterable values) { - _source.addAll(new CastIterable(values)); + _source.addAll(CastIterable(values)); } void sort([int Function(T v1, T v2)? compare]) { @@ -132,11 +132,11 @@ abstract class _CastListBase extends _CastIterableBase } void insertAll(int index, Iterable elements) { - _source.insertAll(index, new CastIterable(elements)); + _source.insertAll(index, CastIterable(elements)); } void setAll(int index, Iterable elements) { - _source.setAll(index, new CastIterable(elements)); + _source.setAll(index, CastIterable(elements)); } bool remove(Object? value) => _source.remove(value); @@ -154,10 +154,10 @@ abstract class _CastListBase extends _CastIterableBase } Iterable getRange(int start, int end) => - new CastIterable(_source.getRange(start, end)); + CastIterable(_source.getRange(start, end)); void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { - _source.setRange(start, end, new CastIterable(iterable), skipCount); + _source.setRange(start, end, CastIterable(iterable), skipCount); } void removeRange(int start, int end) { @@ -169,7 +169,7 @@ abstract class _CastListBase extends _CastIterableBase } void replaceRange(int start, int end, Iterable replacement) { - _source.replaceRange(start, end, new CastIterable(replacement)); + _source.replaceRange(start, end, CastIterable(replacement)); } } @@ -177,7 +177,7 @@ class CastList extends _CastListBase { final List _source; CastList(this._source); - List cast() => new CastList(_source); + List cast() => CastList(_source); } class CastSet extends _CastIterableBase implements Set { @@ -190,11 +190,11 @@ class CastSet extends _CastIterableBase implements Set { CastSet(this._source, this._emptySet); - Set cast() => new CastSet(_source, _emptySet); + Set cast() => CastSet(_source, _emptySet); bool add(T value) => _source.add(value as S); void addAll(Iterable elements) { - _source.addAll(new CastIterable(elements)); + _source.addAll(CastIterable(elements)); } bool remove(Object? object) => _source.remove(object); @@ -219,17 +219,17 @@ class CastSet extends _CastIterableBase implements Set { Set intersection(Set other) { if (_emptySet != null) return _conditionalAdd(other, true); - return new CastSet(_source.intersection(other), null); + return CastSet(_source.intersection(other), null); } Set difference(Set other) { if (_emptySet != null) return _conditionalAdd(other, false); - return new CastSet(_source.difference(other), null); + return CastSet(_source.difference(other), null); } Set _conditionalAdd(Set other, bool otherContains) { var emptySet = _emptySet; - Set result = (emptySet == null) ? new Set() : emptySet(); + Set result = (emptySet == null) ? Set() : emptySet(); for (var element in _source) { T castElement = element as T; if (otherContains == other.contains(castElement)) result.add(castElement); @@ -245,7 +245,7 @@ class CastSet extends _CastIterableBase implements Set { Set _clone() { var emptySet = _emptySet; - Set result = (emptySet == null) ? new Set() : emptySet(); + Set result = (emptySet == null) ? Set() : emptySet(); result.addAll(this); return result; } @@ -260,7 +260,7 @@ class CastMap extends MapBase { CastMap(this._source); - Map cast() => new CastMap(_source); + Map cast() => CastMap(_source); bool containsValue(Object? value) => _source.containsValue(value); @@ -276,7 +276,7 @@ class CastMap extends MapBase { _source.putIfAbsent(key as SK, () => ifAbsent() as SV) as V; void addAll(Map other) { - _source.addAll(new CastMap(other)); + _source.addAll(CastMap(other)); } V? remove(Object? key) => _source.remove(key) as V?; @@ -291,9 +291,9 @@ class CastMap extends MapBase { }); } - Iterable get keys => new CastIterable(_source.keys); + Iterable get keys => CastIterable(_source.keys); - Iterable get values => new CastIterable(_source.values); + Iterable get values => CastIterable(_source.values); int get length => _source.length; @@ -316,7 +316,7 @@ class CastMap extends MapBase { Iterable> get entries { return _source.entries.map>( - (MapEntry e) => new MapEntry(e.key as K, e.value as V), + (MapEntry e) => MapEntry(e.key as K, e.value as V), ); } @@ -334,7 +334,7 @@ class CastMap extends MapBase { class CastQueue extends _CastIterableBase implements Queue { final Queue _source; CastQueue(this._source); - Queue cast() => new CastQueue(_source); + Queue cast() => CastQueue(_source); T removeFirst() => _source.removeFirst() as T; T removeLast() => _source.removeLast() as T; @@ -353,7 +353,7 @@ class CastQueue extends _CastIterableBase implements Queue { bool remove(Object? other) => _source.remove(other); void addAll(Iterable elements) { - _source.addAll(new CastIterable(elements)); + _source.addAll(CastIterable(elements)); } void removeWhere(bool test(T element)) { diff --git a/sdk/lib/internal/internal.dart b/sdk/lib/internal/internal.dart index 6ba8eb95a83..231592ed767 100644 --- a/sdk/lib/internal/internal.dart +++ b/sdk/lib/internal/internal.dart @@ -57,7 +57,7 @@ external T unsafeCast(dynamic value); // Powers of 10 up to 10^22 are representable as doubles. // Powers of 10 above that are only approximate due to lack of precision. // Used by double-parsing. -const POWERS_OF_TEN = const [ +const POWERS_OF_TEN = [ 1.0, // 0 10.0, 100.0, @@ -742,7 +742,7 @@ class SentinelValue { } /// A default value to use when only one sentinel is needed. -const Object sentinelValue = const SentinelValue(0); +const Object sentinelValue = SentinelValue(0); /// Given an [instance] of some generic type [T], and [extract], a first-class /// generic function that takes the same number of type parameters as [T], diff --git a/sdk/lib/internal/linked_list.dart b/sdk/lib/internal/linked_list.dart index 598f583a17d..bd2ea92308e 100644 --- a/sdk/lib/internal/linked_list.dart +++ b/sdk/lib/internal/linked_list.dart @@ -75,7 +75,7 @@ class LinkedList> extends Iterable { node._list = null; } - Iterator get iterator => new _LinkedListIterator(this); + Iterator get iterator => _LinkedListIterator(this); } class LinkedListEntry> { diff --git a/sdk/lib/internal/list.dart b/sdk/lib/internal/list.dart index 3f0e3b580b3..42d35ac2bfc 100644 --- a/sdk/lib/internal/list.dart +++ b/sdk/lib/internal/list.dart @@ -12,69 +12,67 @@ part of dart._internal; mixin FixedLengthListMixin { /** This operation is not supported by a fixed length list. */ set length(int newLength) { - throw new UnsupportedError( - "Cannot change the length of a fixed-length list", - ); + throw UnsupportedError("Cannot change the length of a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void add(E value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void insert(int index, E value) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void insertAll(int at, Iterable iterable) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void addAll(Iterable iterable) { - throw new UnsupportedError("Cannot add to a fixed-length list"); + throw UnsupportedError("Cannot add to a fixed-length list"); } /** This operation is not supported by a fixed length list. */ bool remove(Object? element) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void removeWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void retainWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void clear() { - throw new UnsupportedError("Cannot clear a fixed-length list"); + throw UnsupportedError("Cannot clear a fixed-length list"); } /** This operation is not supported by a fixed length list. */ E removeAt(int index) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ E removeLast() { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void removeRange(int start, int end) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } /** This operation is not supported by a fixed length list. */ void replaceRange(int start, int end, Iterable iterable) { - throw new UnsupportedError("Cannot remove from a fixed-length list"); + throw UnsupportedError("Cannot remove from a fixed-length list"); } } @@ -88,107 +86,105 @@ mixin FixedLengthListMixin { mixin UnmodifiableListMixin implements List { /** This operation is not supported by an unmodifiable list. */ void operator []=(int index, E value) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ set length(int newLength) { - throw new UnsupportedError( - "Cannot change the length of an unmodifiable list", - ); + throw UnsupportedError("Cannot change the length of an unmodifiable list"); } set first(E element) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } set last(E element) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void setAll(int at, Iterable iterable) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void add(E value) { - throw new UnsupportedError("Cannot add to an unmodifiable list"); + throw UnsupportedError("Cannot add to an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void insert(int index, E element) { - throw new UnsupportedError("Cannot add to an unmodifiable list"); + throw UnsupportedError("Cannot add to an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void insertAll(int at, Iterable iterable) { - throw new UnsupportedError("Cannot add to an unmodifiable list"); + throw UnsupportedError("Cannot add to an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void addAll(Iterable iterable) { - throw new UnsupportedError("Cannot add to an unmodifiable list"); + throw UnsupportedError("Cannot add to an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ bool remove(Object? element) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void removeWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void retainWhere(bool test(E element)) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void sort([Comparator? compare]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void shuffle([Random? random]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void clear() { - throw new UnsupportedError("Cannot clear an unmodifiable list"); + throw UnsupportedError("Cannot clear an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ E removeAt(int index) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ E removeLast() { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void setRange(int start, int end, Iterable iterable, [int skipCount = 0]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void removeRange(int start, int end) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void replaceRange(int start, int end, Iterable iterable) { - throw new UnsupportedError("Cannot remove from an unmodifiable list"); + throw UnsupportedError("Cannot remove from an unmodifiable list"); } /** This operation is not supported by an unmodifiable list. */ void fillRange(int start, int end, [E? fillValue]) { - throw new UnsupportedError("Cannot modify an unmodifiable list"); + throw UnsupportedError("Cannot modify an unmodifiable list"); } } @@ -230,8 +226,8 @@ class ListMapView extends UnmodifiableMapBase { E? operator [](Object? key) => containsKey(key) ? _values[key as int] : null; int get length => _values.length; - Iterable get values => new SubListIterable(_values, 0, null); - Iterable get keys => new _ListIndicesIterable(_values); + Iterable get values => SubListIterable(_values, 0, null); + Iterable get keys => _ListIndicesIterable(_values); bool get isEmpty => _values.isEmpty; bool get isNotEmpty => _values.isNotEmpty; @@ -243,7 +239,7 @@ class ListMapView extends UnmodifiableMapBase { for (int i = 0; i < length; i++) { f(i, _values[i]); if (length != _values.length) { - throw new ConcurrentModificationError(_values); + throw ConcurrentModificationError(_values); } } } @@ -266,19 +262,19 @@ final class ReversedListIterable extends ListIterable { abstract class UnmodifiableListError { /** Error thrown when trying to add elements to an unmodifiable list. */ static UnsupportedError add() => - new UnsupportedError("Cannot add to unmodifiable List"); + UnsupportedError("Cannot add to unmodifiable List"); /** Error thrown when trying to add elements to an unmodifiable list. */ static UnsupportedError change() => - new UnsupportedError("Cannot change the content of an unmodifiable List"); + UnsupportedError("Cannot change the content of an unmodifiable List"); /** Error thrown when trying to change the length of an unmodifiable list. */ static UnsupportedError length() => - new UnsupportedError("Cannot change length of unmodifiable List"); + UnsupportedError("Cannot change length of unmodifiable List"); /** Error thrown when trying to remove elements from an unmodifiable list. */ static UnsupportedError remove() => - new UnsupportedError("Cannot remove from unmodifiable List"); + UnsupportedError("Cannot remove from unmodifiable List"); } /** @@ -289,15 +285,15 @@ abstract class UnmodifiableListError { abstract class NonGrowableListError { /** Error thrown when trying to add elements to an non-growable list. */ static UnsupportedError add() => - new UnsupportedError("Cannot add to non-growable List"); + UnsupportedError("Cannot add to non-growable List"); /** Error thrown when trying to change the length of an non-growable list. */ static UnsupportedError length() => - new UnsupportedError("Cannot change length of non-growable List"); + UnsupportedError("Cannot change length of non-growable List"); /** Error thrown when trying to remove elements from an non-growable list. */ static UnsupportedError remove() => - new UnsupportedError("Cannot remove from non-growable List"); + UnsupportedError("Cannot remove from non-growable List"); } /** diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart index 42442cf8cfa..85d67cb4b56 100644 --- a/sdk/lib/io/common.dart +++ b/sdk/lib/io/common.dart @@ -92,7 +92,7 @@ class OSError implements Exception { /// Converts an OSError object to a string representation. String toString() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = StringBuffer(); sb.write("OS Error"); if (message.isNotEmpty) { sb @@ -129,12 +129,12 @@ _BufferAndStart _ensureFastAndSerializableByteData( // Send typed data directly, unless it is a partial view, in which case we // would rather copy than drag in the potentially much large backing store. // See issue 50206. - return new _BufferAndStart(buffer, start); + return _BufferAndStart(buffer, start); } int length = end - start; - var newBuffer = new Uint8List(length); + var newBuffer = Uint8List(length); newBuffer.setRange(0, length, buffer, start); - return new _BufferAndStart(newBuffer, 0); + return _BufferAndStart(newBuffer, 0); } class _IOCrypto { diff --git a/sdk/lib/io/data_transformer.dart b/sdk/lib/io/data_transformer.dart index 7eb237facd9..0981cc642f6 100644 --- a/sdk/lib/io/data_transformer.dart +++ b/sdk/lib/io/data_transformer.dart @@ -56,7 +56,7 @@ abstract final class ZLibOption { } /// An instance of the default implementation of the [ZLibCodec]. -const ZLibCodec zlib = const ZLibCodec._default(); +const ZLibCodec zlib = ZLibCodec._default(); /// The [ZLibCodec] encodes raw bytes to ZLib compressed bytes and decodes ZLib /// compressed bytes to raw bytes. @@ -131,7 +131,7 @@ final class ZLibCodec extends Codec, List> { dictionary = null; /// Get a [ZLibEncoder] for encoding to `ZLib` compressed data. - ZLibEncoder get encoder => new ZLibEncoder( + ZLibEncoder get encoder => ZLibEncoder( gzip: false, level: level, windowBits: windowBits, @@ -143,11 +143,11 @@ final class ZLibCodec extends Codec, List> { /// Get a [ZLibDecoder] for decoding `ZLib` compressed data. ZLibDecoder get decoder => - new ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw); + ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw); } /// An instance of the default implementation of the [GZipCodec]. -const GZipCodec gzip = const GZipCodec._default(); +const GZipCodec gzip = GZipCodec._default(); /// The [GZipCodec] encodes raw bytes to GZip compressed bytes and decodes GZip /// compressed bytes to raw bytes. @@ -224,7 +224,7 @@ final class GZipCodec extends Codec, List> { dictionary = null; /// Get a [ZLibEncoder] for encoding to `GZip` compressed data. - ZLibEncoder get encoder => new ZLibEncoder( + ZLibEncoder get encoder => ZLibEncoder( gzip: true, level: level, windowBits: windowBits, @@ -235,7 +235,7 @@ final class GZipCodec extends Codec, List> { ); /// Get a [ZLibDecoder] for decoding `GZip` compressed data. - ZLibDecoder get decoder => new ZLibDecoder( + ZLibDecoder get decoder => ZLibDecoder( gzip: true, windowBits: windowBits, dictionary: dictionary, @@ -311,7 +311,7 @@ final class ZLibEncoder extends Converter, List> { /// Convert a list of bytes using the options given to the ZLibEncoder /// constructor. List convert(List bytes) { - _BufferSink sink = new _BufferSink(); + _BufferSink sink = _BufferSink(); startChunkedConversion(sink) ..add(bytes) ..close(); @@ -326,9 +326,9 @@ final class ZLibEncoder extends Converter, List> { /// using it. ByteConversionSink startChunkedConversion(Sink> sink) { if (sink is! ByteConversionSink) { - sink = new ByteConversionSink.from(sink); + sink = ByteConversionSink.from(sink); } - return new _ZLibEncoderSink._( + return _ZLibEncoderSink._( sink, gzip, level, @@ -378,7 +378,7 @@ final class ZLibDecoder extends Converter, List> { /// Convert a list of bytes using the options given to the [ZLibDecoder] /// constructor. List convert(List bytes) { - _BufferSink sink = new _BufferSink(); + _BufferSink sink = _BufferSink(); startChunkedConversion(sink) ..add(bytes) ..close(); @@ -392,9 +392,9 @@ final class ZLibDecoder extends Converter, List> { /// using it. ByteConversionSink startChunkedConversion(Sink> sink) { if (sink is! ByteConversionSink) { - sink = new ByteConversionSink.from(sink); + sink = ByteConversionSink.from(sink); } - return new _ZLibDecoderSink._(sink, gzip, windowBits, dictionary, raw); + return _ZLibDecoderSink._(sink, gzip, windowBits, dictionary, raw); } } @@ -468,7 +468,7 @@ abstract interface class RawZLibFilter { } class _BufferSink extends ByteConversionSink { - final BytesBuilder builder = new BytesBuilder(copy: false); + final BytesBuilder builder = BytesBuilder(copy: false); void add(List chunk) { builder.add(chunk); @@ -478,11 +478,7 @@ class _BufferSink extends ByteConversionSink { if (chunk is Uint8List) { Uint8List list = chunk; builder.add( - new Uint8List.view( - list.buffer, - list.offsetInBytes + start, - end - start, - ), + Uint8List.view(list.buffer, list.offsetInBytes + start, end - start), ); } else { builder.add(chunk.sublist(start, end)); @@ -594,7 +590,7 @@ class _FilterSink extends ByteConversionSink { void _validateZLibWindowBits(int windowBits) { if (ZLibOption.minWindowBits > windowBits || ZLibOption.maxWindowBits < windowBits) { - throw new RangeError.range( + throw RangeError.range( windowBits, ZLibOption.minWindowBits, ZLibOption.maxWindowBits, @@ -604,13 +600,13 @@ void _validateZLibWindowBits(int windowBits) { void _validateZLibeLevel(int level) { if (ZLibOption.minLevel > level || ZLibOption.maxLevel < level) { - throw new RangeError.range(level, ZLibOption.minLevel, ZLibOption.maxLevel); + throw RangeError.range(level, ZLibOption.minLevel, ZLibOption.maxLevel); } } void _validateZLibMemLevel(int memLevel) { if (ZLibOption.minMemLevel > memLevel || ZLibOption.maxMemLevel < memLevel) { - throw new RangeError.range( + throw RangeError.range( memLevel, ZLibOption.minMemLevel, ZLibOption.maxMemLevel, @@ -619,7 +615,7 @@ void _validateZLibMemLevel(int memLevel) { } void _validateZLibStrategy(int strategy) { - const strategies = const [ + const strategies = [ ZLibOption.strategyFiltered, ZLibOption.strategyHuffmanOnly, ZLibOption.strategyRle, @@ -627,6 +623,6 @@ void _validateZLibStrategy(int strategy) { ZLibOption.strategyDefault, ]; if (strategies.indexOf(strategy) == -1) { - throw new ArgumentError("Unsupported 'strategy'"); + throw ArgumentError("Unsupported 'strategy'"); } } diff --git a/sdk/lib/io/directory.dart b/sdk/lib/io/directory.dart index 74c51f453e4..88d34a2e62f 100644 --- a/sdk/lib/io/directory.dart +++ b/sdk/lib/io/directory.dart @@ -112,7 +112,7 @@ abstract interface class Directory implements FileSystemEntity { factory Directory(String path) { final IOOverrides? overrides = IOOverrides.current; if (overrides == null) { - return new _Directory(path); + return _Directory(path); } return overrides.createDirectory(path); } @@ -120,13 +120,13 @@ abstract interface class Directory implements FileSystemEntity { @pragma("vm:entry-point") factory Directory.fromRawPath(Uint8List path) { // TODO(bkonyi): Handle overrides. - return new _Directory.fromRawPath(path); + return _Directory.fromRawPath(path); } /// Create a [Directory] from a URI. /// /// If [uri] cannot reference a directory this throws [UnsupportedError]. - factory Directory.fromUri(Uri uri) => new Directory(uri.toFilePath()); + factory Directory.fromUri(Uri uri) => Directory(uri.toFilePath()); /// Creates a directory object pointing to the current working /// directory. diff --git a/sdk/lib/io/directory_impl.dart b/sdk/lib/io/directory_impl.dart index fa57c478230..86f42e7a360 100644 --- a/sdk/lib/io/directory_impl.dart +++ b/sdk/lib/io/directory_impl.dart @@ -53,7 +53,7 @@ class _Directory extends FileSystemEntity implements Directory { "", ); } - return new _Directory(result); + return _Directory(result); } static void set current(Object? path) { @@ -72,7 +72,7 @@ class _Directory extends FileSystemEntity implements Directory { }; if (!_EmbedderConfig._mayChdir) { - throw new UnsupportedError( + throw UnsupportedError( "This embedder disallows setting Directory.current", ); } @@ -88,7 +88,7 @@ class _Directory extends FileSystemEntity implements Directory { } Uri get uri { - return new Uri.directory(path); + return Uri.directory(path); } Future exists() { @@ -104,12 +104,12 @@ class _Directory extends FileSystemEntity implements Directory { bool existsSync() { var result = _exists(_Namespace._namespace, _rawPath); if (result is OSError) { - throw new FileSystemException("Exists failed", path, result); + throw FileSystemException("Exists failed", path, result); } return (result == 1); } - Directory get absolute => new Directory(_absolutePath); + Directory get absolute => Directory(_absolutePath); Future create({bool recursive = false}) { if (recursive) { @@ -148,12 +148,12 @@ class _Directory extends FileSystemEntity implements Directory { } static Directory get systemTemp => - new Directory(_systemTemp(_Namespace._namespace)); + Directory(_systemTemp(_Namespace._namespace)); Future createTemp([String? prefix]) { prefix ??= ''; if (path == '') { - throw new ArgumentError( + throw ArgumentError( "Directory.createTemp called with an empty path. " "To use the system temp directory, use Directory.systemTemp", ); @@ -182,7 +182,7 @@ class _Directory extends FileSystemEntity implements Directory { Directory createTempSync([String? prefix]) { prefix ??= ''; if (path == '') { - throw new ArgumentError( + throw ArgumentError( "Directory.createTemp called with an empty path. " "To use the system temp directory, use Directory.systemTemp", ); @@ -200,13 +200,13 @@ class _Directory extends FileSystemEntity implements Directory { FileSystemEntity._toUtf8Array(fullPrefix), ); if (result is OSError) { - throw new FileSystemException._fromOSError( + throw FileSystemException._fromOSError( result, "Creation of temporary directory failed", fullPrefix, ); } - return new Directory(result); + return Directory(result); } Future _delete({bool recursive = false}) { @@ -234,7 +234,7 @@ class _Directory extends FileSystemEntity implements Directory { newPath, ]).then((response) { _checkForErrorResponse(response, "Rename failed", path); - return new Directory(newPath); + return Directory(newPath); }); } @@ -245,14 +245,14 @@ class _Directory extends FileSystemEntity implements Directory { if (result is OSError) { throw FileSystemException._fromOSError(result, "Rename failed", path); } - return new Directory(newPath); + return Directory(newPath); } Stream list({ bool recursive = false, bool followLinks = true, }) { - return new _AsyncDirectoryLister( + return _AsyncDirectoryLister( // FIXME(bkonyi): here we're using `path` directly, which might cause issues // if it is not UTF-8 encoded. FileSystemEntity._toUtf8Array( @@ -316,12 +316,12 @@ class _AsyncDirectoryLister { final bool recursive; final bool followLinks; - final controller = new StreamController(sync: true); + final controller = StreamController(sync: true); bool canceled = false; bool nextRunning = false; bool closed = false; _AsyncDirectoryListerOps? _ops; - Completer closeCompleter = new Completer(); + Completer closeCompleter = Completer(); _AsyncDirectoryLister(this.rawPath, this.recursive, this.followLinks) { controller @@ -349,7 +349,7 @@ class _AsyncDirectoryLister { followLinks, ]).then((response) { if (response is int) { - _ops = new _AsyncDirectoryListerOps(response); + _ops = _AsyncDirectoryListerOps(response); next(); } else if (response is Error) { controller.addError(response, response.stackTrace); @@ -401,13 +401,13 @@ class _AsyncDirectoryLister { assert(i % 2 == 0); switch (result[i++]) { case listFile: - controller.add(new File.fromRawPath(result[i])); + controller.add(File.fromRawPath(result[i])); break; case listDirectory: - controller.add(new Directory.fromRawPath(result[i])); + controller.add(Directory.fromRawPath(result[i])); break; case listLink: - controller.add(new Link.fromRawPath(result[i])); + controller.add(Link.fromRawPath(result[i])); break; case listError: error(result[i]); @@ -418,7 +418,7 @@ class _AsyncDirectoryLister { } } } else { - controller.addError(new FileSystemException("Internal error")); + controller.addError(FileSystemException("Internal error")); } }); } @@ -452,9 +452,9 @@ class _AsyncDirectoryLister { var errorResponseInfo = message[responseError]! as List; var errorType = errorResponseInfo[_errorResponseErrorType]; if (errorType == _illegalArgumentResponse) { - controller.addError(new ArgumentError()); + controller.addError(ArgumentError()); } else if (errorType == _osErrorResponse) { - var err = new OSError( + var err = OSError( errorResponseInfo[_osErrorResponseMessage] as String, errorResponseInfo[_osErrorResponseErrorCode] as int, ); @@ -472,7 +472,7 @@ class _AsyncDirectoryLister { ), ); } else { - controller.addError(new FileSystemException("Internal error")); + controller.addError(FileSystemException("Internal error")); } } } diff --git a/sdk/lib/io/file.dart b/sdk/lib/io/file.dart index 58460541a21..d1fe18eee53 100644 --- a/sdk/lib/io/file.dart +++ b/sdk/lib/io/file.dart @@ -7,25 +7,25 @@ part of dart.io; /// The modes in which a [File] can be opened. class FileMode { /// The mode for opening a file only for reading. - static const read = const FileMode._internal(0); + static const read = FileMode._internal(0); /// Mode for opening a file for reading and writing. The file is /// overwritten if it already exists. The file is created if it does not /// already exist. - static const write = const FileMode._internal(1); + static const write = FileMode._internal(1); /// Mode for opening a file for reading and writing to the /// end of it. The file is created if it does not already exist. - static const append = const FileMode._internal(2); + static const append = FileMode._internal(2); /// Mode for opening a file for writing *only*. The file is /// overwritten if it already exists. The file is created if it does not /// already exist. - static const writeOnly = const FileMode._internal(3); + static const writeOnly = FileMode._internal(3); /// Mode for opening a file for writing *only* to the /// end of it. The file is created if it does not already exist. - static const writeOnlyAppend = const FileMode._internal(4); + static const writeOnlyAppend = FileMode._internal(4); final int _mode; @@ -35,16 +35,16 @@ class FileMode { /// Type of lock when requesting a lock on a file. class FileLock { /// Shared file lock. - static const shared = const FileLock._internal(1); + static const shared = FileLock._internal(1); /// Exclusive file lock. - static const exclusive = const FileLock._internal(2); + static const exclusive = FileLock._internal(2); /// Blocking shared file lock. - static const blockingShared = const FileLock._internal(3); + static const blockingShared = FileLock._internal(3); /// Blocking exclusive file lock. - static const blockingExclusive = const FileLock._internal(4); + static const blockingExclusive = FileLock._internal(4); final int _type; @@ -201,7 +201,7 @@ abstract interface class File implements FileSystemEntity { factory File(String path) { final IOOverrides? overrides = IOOverrides.current; if (overrides == null) { - return new _File(path); + return _File(path); } return overrides.createFile(path); } @@ -209,7 +209,7 @@ abstract interface class File implements FileSystemEntity { /// Create a [File] object from a URI. /// /// If [uri] cannot reference a file this throws [UnsupportedError]. - factory File.fromUri(Uri uri) => new File(uri.toFilePath()); + factory File.fromUri(Uri uri) => File(uri.toFilePath()); /// Creates a [File] object from a raw path. /// @@ -217,7 +217,7 @@ abstract interface class File implements FileSystemEntity { @pragma("vm:entry-point") factory File.fromRawPath(Uint8List rawPath) { // TODO(bkonyi): Handle overrides. - return new _File.fromRawPath(rawPath); + return _File.fromRawPath(rawPath); } /// Creates the file. @@ -1120,7 +1120,7 @@ class FileSystemException implements IOException { } String _toStringHelper(String className) { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = StringBuffer(); sb.write(className); if (message.isNotEmpty) { sb.write(": $message"); diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart index 57e59bb562e..9ecf5401e46 100644 --- a/sdk/lib/io/io_sink.dart +++ b/sdk/lib/io/io_sink.dart @@ -31,7 +31,7 @@ abstract interface class IOSink implements StreamSink>, StringSink { factory IOSink( StreamConsumer> target, { Encoding encoding = utf8, - }) => new _IOSinkImpl(target, encoding); + }) => _IOSinkImpl(target, encoding); /// The [Encoding] used when writing strings. /// @@ -139,7 +139,7 @@ abstract interface class IOSink implements StreamSink>, StringSink { class _StreamSinkImpl implements StreamSink { final StreamConsumer _target; - final Completer _doneCompleter = new Completer(); + final Completer _doneCompleter = Completer(); StreamController? _controllerInstance; Completer? _controllerCompleter; bool _isClosed = false; @@ -164,7 +164,7 @@ class _StreamSinkImpl implements StreamSink { Future addStream(Stream stream) { if (_isBound) { - throw new StateError("StreamSink is already bound to a stream"); + throw StateError("StreamSink is already bound to a stream"); } if (_hasError) return done; @@ -186,9 +186,9 @@ class _StreamSinkImpl implements StreamSink { Future flush() { if (_isBound) { - throw new StateError("StreamSink is bound to a stream"); + throw StateError("StreamSink is bound to a stream"); } - if (_controllerInstance == null) return new Future.value(this); + if (_controllerInstance == null) return Future.value(this); // Adding an empty stream-controller will return a future that will complete // when all data is done. _isBound = true; @@ -201,7 +201,7 @@ class _StreamSinkImpl implements StreamSink { Future close() { if (_isBound) { - throw new StateError("StreamSink is bound to a stream"); + throw StateError("StreamSink is bound to a stream"); } if (!_isClosed) { _isClosed = true; @@ -235,14 +235,14 @@ class _StreamSinkImpl implements StreamSink { StreamController get _controller { if (_isBound) { - throw new StateError("StreamSink is bound to a stream"); + throw StateError("StreamSink is bound to a stream"); } if (_isClosed) { - throw new StateError("StreamSink is closed"); + throw StateError("StreamSink is closed"); } if (_controllerInstance == null) { - _controllerInstance = new StreamController(sync: true); - _controllerCompleter = new Completer(); + _controllerInstance = StreamController(sync: true); + _controllerCompleter = Completer(); _target .addStream(_controller.stream) .then( @@ -285,7 +285,7 @@ class _IOSinkImpl extends _StreamSinkImpl> implements IOSink { void set encoding(Encoding value) { if (!_encodingMutable) { - throw new StateError("IOSink encoding is not mutable"); + throw StateError("IOSink encoding is not mutable"); } _encoding = value; } @@ -317,6 +317,6 @@ class _IOSinkImpl extends _StreamSinkImpl> implements IOSink { } void writeCharCode(int charCode) { - write(new String.fromCharCode(charCode)); + write(String.fromCharCode(charCode)); } } diff --git a/sdk/lib/io/network_profiling.dart b/sdk/lib/io/network_profiling.dart index b61eeab291d..6f057ff78cb 100644 --- a/sdk/lib/io/network_profiling.dart +++ b/sdk/lib/io/network_profiling.dart @@ -39,7 +39,7 @@ Map _createHttpProfileRequestFromProfileMap( }; } -@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product")) +@pragma('vm:entry-point', !bool.fromEnvironment("dart.vm.product")) abstract class _NetworkProfiling { // Http relative RPCs static const _kHttpEnableTimelineLogging = @@ -58,7 +58,7 @@ abstract class _NetworkProfiling { // if more methods added to dart:io, static const _kGetVersionRPC = 'ext.dart.io.getVersion'; - @pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product")) + @pragma('vm:entry-point', !bool.fromEnvironment("dart.vm.product")) static void _registerServiceExtension() { registerExtension(_kHttpEnableTimelineLogging, _serviceExtensionHandler); registerExtension(_kGetSocketProfileRPC, _serviceExtensionHandler); diff --git a/sdk/lib/io/overrides.dart b/sdk/lib/io/overrides.dart index adaf613022d..31df3f47577 100644 --- a/sdk/lib/io/overrides.dart +++ b/sdk/lib/io/overrides.dart @@ -4,7 +4,7 @@ part of dart.io; -final _ioOverridesToken = new Object(); +final _ioOverridesToken = Object(); /// Facilities for overriding various APIs of `dart:io` with mock /// implementations. @@ -117,7 +117,7 @@ abstract class IOOverrides { currentScope = current; current = currentScope._previous; } - IOOverrides overrides = new _IOOverridesScope( + IOOverrides overrides = _IOOverridesScope( current, // Directory createDirectory ?? currentScope?._createDirectory, @@ -180,7 +180,7 @@ abstract class IOOverrides { /// /// When this override is installed, this function overrides the behavior of /// `new Directory()` and `new Directory.fromUri()`. - Directory createDirectory(String path) => new _Directory(path); + Directory createDirectory(String path) => _Directory(path); /// Returns the current working directory. /// @@ -208,7 +208,7 @@ abstract class IOOverrides { /// /// When this override is installed, this function overrides the behavior of /// `new File()` and `new File.fromUri()`. - File createFile(String path) => new _File(path); + File createFile(String path) => _File(path); // FileStat @@ -286,7 +286,7 @@ abstract class IOOverrides { /// /// When this override is installed, this function overrides the behavior of /// `new Link()` and `new Link.fromUri()`. - Link createLink(String path) => new _Link(path); + Link createLink(String path) => _Link(path); // Socket diff --git a/sdk/lib/io/platform_impl.dart b/sdk/lib/io/platform_impl.dart index 526c44b71f6..130cf6bc244 100644 --- a/sdk/lib/io/platform_impl.dart +++ b/sdk/lib/io/platform_impl.dart @@ -84,8 +84,8 @@ class _Platform { if (env is Iterable) { var result = Platform.isWindows - ? new _CaseInsensitiveStringMap() - : new Map(); + ? _CaseInsensitiveStringMap() + : Map(); for (var environmentEntry in env) { if (environmentEntry == null) { continue; @@ -107,7 +107,7 @@ class _Platform { ); } } - _environmentCache = new UnmodifiableMapView(result); + _environmentCache = UnmodifiableMapView(result); } else { _environmentCache = env; } @@ -126,7 +126,7 @@ class _Platform { // Environment variables are case-insensitive on Windows. In order // to reflect that we use a case-insensitive string map on Windows. class _CaseInsensitiveStringMap extends MapBase { - final Map _map = new Map(); + final Map _map = Map(); bool containsKey(Object? key) => key is String && _map.containsKey(key.toUpperCase()); diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart index d4f210016db..ebd4e6c9d6b 100644 --- a/sdk/lib/io/secure_socket.dart +++ b/sdk/lib/io/secure_socket.dart @@ -68,7 +68,7 @@ abstract interface class SecureSocket implements Socket { keyLog: keyLog, supportedProtocols: supportedProtocols, timeout: timeout, - ).then((rawSocket) => new SecureSocket._(rawSocket)); + ).then((rawSocket) => SecureSocket._(rawSocket)); } /// Like [connect], but returns a [Future] that completes with a @@ -91,9 +91,9 @@ abstract interface class SecureSocket implements Socket { supportedProtocols: supportedProtocols, ).then((rawState) { Future socket = rawState.socket.then( - (rawSocket) => new SecureSocket._(rawSocket), + (rawSocket) => SecureSocket._(rawSocket), ); - return new ConnectionTask._(socket, rawState._onCancel); + return ConnectionTask._(socket, rawState._onCancel); }); } @@ -170,7 +170,7 @@ abstract interface class SecureSocket implements Socket { supportedProtocols: supportedProtocols, ); }) - .then((raw) => new SecureSocket._(raw)); + .then((raw) => SecureSocket._(raw)); } /// Initiates TLS on an existing server connection. @@ -214,7 +214,7 @@ abstract interface class SecureSocket implements Socket { supportedProtocols: supportedProtocols, ); }) - .then((raw) => new SecureSocket._(raw)); + .then((raw) => SecureSocket._(raw)); } /// The peer certificate for a connected SecureSocket. @@ -343,7 +343,7 @@ abstract interface class RawSecureSocket implements RawSocket { supportedProtocols: supportedProtocols, ); }); - return new ConnectionTask._(socket, rawState._onCancel); + return ConnectionTask._(socket, rawState._onCancel); }); } @@ -559,8 +559,8 @@ class _RawSecureSocket extends Stream final RawSocket _socket; final Completer<_RawSecureSocket> _handshakeComplete = - new Completer<_RawSecureSocket>(); - final _controller = new StreamController(sync: true); + Completer<_RawSecureSocket>(); + final _controller = StreamController(sync: true); late final StreamSubscription _socketSubscription; List? _bufferedData; int _bufferedDataIndex = 0; @@ -583,13 +583,13 @@ class _RawSecureSocket extends Stream bool _closedRead = false; // The secure socket has fired an onClosed event. bool _closedWrite = false; // The secure socket has been closed for writing. // The network socket is gone. - Completer _closeCompleter = new Completer(); - _FilterStatus _filterStatus = new _FilterStatus(); + Completer _closeCompleter = Completer(); + _FilterStatus _filterStatus = _FilterStatus(); bool _connectPending = true; bool _filterPending = false; bool _filterActive = false; - _SecureFilter? _secureFilter = new _SecureFilter._(); + _SecureFilter? _secureFilter = _SecureFilter._(); String? _selectedProtocol; static Future<_RawSecureSocket> connect( @@ -617,7 +617,7 @@ class _RawSecureSocket extends Stream if (host != null) { address = InternetAddress._cloneWithNewHost(address, host); } - return new _RawSecureSocket( + return _RawSecureSocket( address, requestedPort, isServer, @@ -693,7 +693,7 @@ class _RawSecureSocket extends Stream _socketSubscription = subscription; if (_socketSubscription.isPaused) { _socket.close(); - throw new ArgumentError("Subscription passed to TLS upgrade is paused"); + throw ArgumentError("Subscription passed to TLS upgrade is paused"); } // If we are upgrading a socket that is already closed for read, // report an error as if we received readClosed during the handshake. @@ -745,7 +745,7 @@ class _RawSecureSocket extends Stream bool requireClientCertificate, ) { if (host is! String && host is! InternetAddress) { - throw new ArgumentError("host is not a String or an InternetAddress"); + throw ArgumentError("host is not a String or an InternetAddress"); } // TODO(40614): Remove once non-nullability is sound. ArgumentError.checkNotNull(requestedPort, "requestedPort"); @@ -850,12 +850,12 @@ class _RawSecureSocket extends Stream Uint8List? read([int? length]) { if (length != null && length < 0) { - throw new ArgumentError( + throw ArgumentError( "Invalid length parameter in SecureSocket.read (length: $length)", ); } if (_closedRead) { - throw new SocketException("Reading from a closed socket"); + throw SocketException("Reading from a closed socket"); } if (_status != connectedStatus) { return null; @@ -874,19 +874,19 @@ class _RawSecureSocket extends Stream // Write the data to the socket, and schedule the filter to encrypt it. int write(List data, [int offset = 0, int? bytes]) { if (bytes != null && bytes < 0) { - throw new ArgumentError( + throw ArgumentError( "Invalid bytes parameter in SecureSocket.read (bytes: $bytes)", ); } // TODO(40614): Remove once non-nullability is sound. offset = _fixOffset(offset); if (offset < 0) { - throw new ArgumentError( + throw ArgumentError( "Invalid offset parameter in SecureSocket.read (offset: $offset)", ); } if (_closedWrite) { - _controller.addError(new SocketException("Writing to a closed socket")); + _controller.addError(SocketException("Writing to a closed socket")); return 0; } if (_status != connectedStatus) return 0; @@ -997,7 +997,7 @@ class _RawSecureSocket extends Stream // bytes available we can continue handshake. if (_filterStatus.readEmpty) { _reportError( - new HandshakeException('Connection terminated during handshake'), + HandshakeException('Connection terminated during handshake'), null, ); } @@ -1028,9 +1028,7 @@ class _RawSecureSocket extends Stream bool requireClientCertificate = false, }) { if (_status != connectedStatus) { - throw new HandshakeException( - "Called renegotiate on a non-connected socket", - ); + throw HandshakeException("Called renegotiate on a non-connected socket"); } _status = handshakeStatus; _filterStatus.writeEmpty = false; @@ -1113,7 +1111,7 @@ class _RawSecureSocket extends Stream if (_status == handshakeStatus) { _secureFilter!.handshake(); if (_status == handshakeStatus) { - throw new HandshakeException( + throw HandshakeException( 'Connection terminated during handshake', ); } @@ -1226,7 +1224,7 @@ class _RawSecureSocket extends Stream Future<_FilterStatus> _pushAllFilterStages() async { bool wasInHandshake = _status != connectedStatus; - List args = new List.filled(2 + bufferCount * 2, null); + List args = List.filled(2 + bufferCount * 2, null); args[0] = _secureFilter!._pointer(); args[1] = wasInHandshake; var bufs = _secureFilter!.buffers!; @@ -1242,21 +1240,18 @@ class _RawSecureSocket extends Stream if (wasInHandshake) { // If we're in handshake, throw a handshake error. _reportError( - new HandshakeException('${response[1]} error ${response[0]}'), + HandshakeException('${response[1]} error ${response[0]}'), null, ); } else { // If we're connected, throw a TLS error. - _reportError( - new TlsException('${response[1]} error ${response[0]}'), - null, - ); + _reportError(TlsException('${response[1]} error ${response[0]}'), null); } } int start(int index) => response[2 * index] as int; int end(int index) => response[2 * index + 1] as int; - _FilterStatus status = new _FilterStatus(); + _FilterStatus status = _FilterStatus(); // Compute writeEmpty as "write plaintext buffer and write encrypted // buffer were empty when we started and are empty now". status.writeEmpty = @@ -1371,7 +1366,7 @@ class _ExternalBuffer { bytes = min(bytes, length); } if (bytes == 0) return null; - Uint8List result = new Uint8List(bytes); + Uint8List result = Uint8List(bytes); int bytesRead = 0; // Loop over zero, one, or two linear data ranges. while (bytesRead < bytes) { @@ -1477,7 +1472,7 @@ class TlsException implements IOException { const TlsException._(this.type, this.message, this.osError); String toString() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = StringBuffer(); sb.write(type); if (message.isNotEmpty) { sb.write(": $message"); diff --git a/sdk/lib/io/security_context.dart b/sdk/lib/io/security_context.dart index 2b306b1f640..2e6ddb0343f 100644 --- a/sdk/lib/io/security_context.dart +++ b/sdk/lib/io/security_context.dart @@ -231,7 +231,7 @@ abstract final class SecurityContext { /// We will be conservative and support only messages up to (1<<13)-1 bytes. static Uint8List _protocolsToLengthEncoding(List? protocols) { if (protocols == null || protocols.length == 0) { - return new Uint8List(0); + return Uint8List(0); } int protocolsLength = protocols.length; @@ -242,20 +242,18 @@ abstract final class SecurityContext { if (length > 0 && length <= 255) { expectedLength += length; } else { - throw new ArgumentError( + throw ArgumentError( 'Length of protocol must be between 1 and 255 (was: $length).', ); } } if (expectedLength >= (1 << 13)) { - throw new ArgumentError( - 'The maximum message length supported is 2^13-1.', - ); + throw ArgumentError('The maximum message length supported is 2^13-1.'); } // Try encoding the `List protocols` array using fast ASCII path. - var bytes = new Uint8List(expectedLength); + var bytes = Uint8List(expectedLength); int bytesOffset = 0; for (int i = 0; i < protocolsLength; i++) { String proto = protocols[i]; @@ -287,7 +285,7 @@ abstract final class SecurityContext { var len = protocolBytes.length; if (len > 255) { - throw new ArgumentError( + throw ArgumentError( 'Length of protocol must be between 1 and 255 (was: $len)', ); } @@ -304,11 +302,9 @@ abstract final class SecurityContext { } if (bytes.length >= (1 << 13)) { - throw new ArgumentError( - 'The maximum message length supported is 2^13-1.', - ); + throw ArgumentError('The maximum message length supported is 2^13-1.'); } - return new Uint8List.fromList(bytes); + return Uint8List.fromList(bytes); } } diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart index f758bbff281..5907fedbe8e 100644 --- a/sdk/lib/io/socket.dart +++ b/sdk/lib/io/socket.dart @@ -10,10 +10,10 @@ part of dart.io; /// and Unix domain address are supported. /// Unix domain sockets are available only on Linux, MacOS and Android. final class InternetAddressType { - static const InternetAddressType IPv4 = const InternetAddressType._(0); - static const InternetAddressType IPv6 = const InternetAddressType._(1); - static const InternetAddressType unix = const InternetAddressType._(2); - static const InternetAddressType any = const InternetAddressType._(-1); + static const InternetAddressType IPv4 = InternetAddressType._(0); + static const InternetAddressType IPv6 = InternetAddressType._(1); + static const InternetAddressType unix = InternetAddressType._(2); + static const InternetAddressType any = InternetAddressType._(-1); final int _value; @@ -23,7 +23,7 @@ final class InternetAddressType { if (value == IPv4._value) return IPv4; if (value == IPv6._value) return IPv6; if (value == unix._value) return unix; - throw new ArgumentError("Invalid type: $value"); + throw ArgumentError("Invalid type: $value"); } /// Get the name of the type, e.g. "IPv4" or "IPv6". @@ -362,9 +362,9 @@ abstract interface class ServerSocket implements ServerSocketBase { /// The [SocketDirection] is used as a parameter to [Socket.close] and /// [RawSocket.close] to close a socket in the specified direction(s). final class SocketDirection { - static const SocketDirection receive = const SocketDirection._(0); - static const SocketDirection send = const SocketDirection._(1); - static const SocketDirection both = const SocketDirection._(2); + static const SocketDirection receive = SocketDirection._(0); + static const SocketDirection send = SocketDirection._(1); + static const SocketDirection both = SocketDirection._(2); final _value; @@ -382,12 +382,12 @@ final class SocketOption { /// as an individual TCP packet. /// /// tcpNoDelay is disabled by default. - static const SocketOption tcpNoDelay = const SocketOption._(0); + static const SocketOption tcpNoDelay = SocketOption._(0); - static const SocketOption _ipMulticastLoop = const SocketOption._(1); - static const SocketOption _ipMulticastHops = const SocketOption._(2); - static const SocketOption _ipMulticastIf = const SocketOption._(3); - static const SocketOption _ipBroadcast = const SocketOption._(4); + static const SocketOption _ipMulticastLoop = SocketOption._(1); + static const SocketOption _ipMulticastHops = SocketOption._(2); + static const SocketOption _ipMulticastIf = SocketOption._(3); + static const SocketOption _ipBroadcast = SocketOption._(4); final _value; @@ -531,16 +531,16 @@ final class RawSocketOption { /// ``` class RawSocketEvent { /// An event indicates the socket is ready to be read. - static const RawSocketEvent read = const RawSocketEvent._(0); + static const RawSocketEvent read = RawSocketEvent._(0); /// An event indicates the socket is ready to write. - static const RawSocketEvent write = const RawSocketEvent._(1); + static const RawSocketEvent write = RawSocketEvent._(1); /// An event indicates the reading from the socket is closed - static const RawSocketEvent readClosed = const RawSocketEvent._(2); + static const RawSocketEvent readClosed = RawSocketEvent._(2); /// An event indicates the socket is closed. - static const RawSocketEvent closed = const RawSocketEvent._(3); + static const RawSocketEvent closed = RawSocketEvent._(3); final int _value; @@ -1408,7 +1408,7 @@ class SocketException implements IOException { port = null; String toString() { - StringBuffer sb = new StringBuffer(); + StringBuffer sb = StringBuffer(); sb.write("SocketException"); if (message.isNotEmpty) { sb.write(": $message"); diff --git a/sdk/lib/typed_data/typed_data.dart b/sdk/lib/typed_data/typed_data.dart index 219fe3dca6b..f951199e3db 100644 --- a/sdk/lib/typed_data/typed_data.dart +++ b/sdk/lib/typed_data/typed_data.dart @@ -402,10 +402,10 @@ final class Endian { final bool _littleEndian; const Endian._(this._littleEndian); - static const Endian big = const Endian._(false); - static const Endian little = const Endian._(true); + static const Endian big = Endian._(false); + static const Endian little = Endian._(true); static final Endian host = - (new ByteData.view(new Uint16List.fromList([1]).buffer)).getInt8(0) == 1 + (ByteData.view(Uint16List.fromList([1]).buffer)).getInt8(0) == 1 ? little : big; } diff --git a/sdk/lib/vmservice/vmservice.dart b/sdk/lib/vmservice/vmservice.dart index 934f06c4324..1d195e3005a 100644 --- a/sdk/lib/vmservice/vmservice.dart +++ b/sdk/lib/vmservice/vmservice.dart @@ -876,14 +876,14 @@ class VMService extends MessageRouter { @pragma( 'vm:entry-point', - const bool.fromEnvironment('dart.vm.product') ? false : 'call', + bool.fromEnvironment('dart.vm.product') ? false : 'call', ) RawReceivePort boot() { // Return the port we expect isolate control messages on. return isolateControlPort; } -@pragma('vm:entry-point', !const bool.fromEnvironment('dart.vm.product')) +@pragma('vm:entry-point', !bool.fromEnvironment('dart.vm.product')) // ignore: unused_element void _registerIsolate(int port_id, SendPort sp, String name) => VMService().runningIsolates.isolateStartup(port_id, sp, name);