From ecf78ee1ae6b42fafa9192d74fd39a2008b9f498 Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Tue, 16 Dec 2025 15:07:39 -0800 Subject: [PATCH] [vm/corelib] Cleanup obsolete null checks from the VM patch files TEST=ci Issue: https://github.com/dart-lang/sdk/issues/40614 Change-Id: I019f4e1fb54adaa585c234a6e806ac50213c6d80 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468640 Commit-Queue: Alexander Markov Reviewed-by: Ryan Macnak --- runtime/vm/compiler/recognized_methods_list.h | 2 +- sdk/lib/_internal/vm/bin/common_patch.dart | 2 +- sdk/lib/_internal/vm/bin/process_patch.dart | 12 ---------- sdk/lib/_internal/vm/bin/socket_patch.dart | 24 ------------------- .../_internal/vm/bin/sync_socket_patch.dart | 6 ----- sdk/lib/_internal/vm/lib/async_patch.dart | 2 -- sdk/lib/_internal/vm/lib/string_patch.dart | 16 ------------- .../_internal/vm_shared/lib/bool_patch.dart | 6 +---- 8 files changed, 3 insertions(+), 67 deletions(-) diff --git a/runtime/vm/compiler/recognized_methods_list.h b/runtime/vm/compiler/recognized_methods_list.h index 301bc166c2a..9437dfbb16d 100644 --- a/runtime/vm/compiler/recognized_methods_list.h +++ b/runtime/vm/compiler/recognized_methods_list.h @@ -44,7 +44,7 @@ namespace dart { V(CoreLibrary, _Record, get:_numFields, Record_numFields, 0x7ba4f393) \ V(CoreLibrary, _Record, get:_shape, Record_shape, 0x70c40933) \ V(CoreLibrary, _Record, _fieldAt, Record_fieldAt, 0xb47fa0b3) \ - V(CoreLibrary, _StringBase, _interpolate, StringBaseInterpolate, 0xa2c902d2) \ + V(CoreLibrary, _StringBase, _interpolate, StringBaseInterpolate, 0xc2be3a8b) \ V(CoreLibrary, _StringBase, codeUnitAt, StringBaseCodeUnitAt, 0x17dbf511) \ V(CoreLibrary, _IntegerImplementation, toDouble, IntegerToDouble, \ 0x97557386) \ diff --git a/sdk/lib/_internal/vm/bin/common_patch.dart b/sdk/lib/_internal/vm/bin/common_patch.dart index a6e891436fe..fc3c7eaee1a 100644 --- a/sdk/lib/_internal/vm/bin/common_patch.dart +++ b/sdk/lib/_internal/vm/bin/common_patch.dart @@ -7,7 +7,7 @@ /// patches of that library. We plan to change this when we have a shared front /// end and simply use parts. -import "dart:_internal" show VMLibraryHooks, patch, checkNotNullable, ClassID; +import "dart:_internal" show VMLibraryHooks, patch, ClassID; import "dart:async" show diff --git a/sdk/lib/_internal/vm/bin/process_patch.dart b/sdk/lib/_internal/vm/bin/process_patch.dart index bddf3022a7e..7c458430edc 100644 --- a/sdk/lib/_internal/vm/bin/process_patch.dart +++ b/sdk/lib/_internal/vm/bin/process_patch.dart @@ -90,8 +90,6 @@ class Process { @patch static bool killPid(int pid, [ProcessSignal signal = ProcessSignal.sigterm]) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(signal, "signal"); return _ProcessUtils._killPid(pid, signal.signalNumber); } } @@ -237,14 +235,6 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { bool runInShell, this._mode, ) : super() { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(path, "path"); - ArgumentError.checkNotNull(arguments, "arguments"); - for (int i = 0; i < arguments.length; i++) { - ArgumentError.checkNotNull(arguments[i], "arguments[]"); - } - ArgumentError.checkNotNull(_mode, "mode"); - if (!const bool.fromEnvironment("dart.vm.product") && !connectedResourceHandler) { registerExtension( @@ -583,8 +573,6 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process { _exitCode?.future ?? (throw StateError("Process is detached")); bool kill([ProcessSignal signal = ProcessSignal.sigterm]) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(kill, "kill"); assert(_started); if (_ended) return false; return _ProcessUtils._killPid(pid, signal.signalNumber); diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart index bfbc56d595b..31fa8fb3433 100644 --- a/sdk/lib/_internal/vm/bin/socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/socket_patch.dart @@ -138,16 +138,12 @@ class NetworkInterface { } void _throwOnBadPort(int port) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(port, "port"); if ((port < 0) || (port > 0xFFFF)) { throw ArgumentError("Invalid port $port"); } } void _throwOnBadTtl(int ttl) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(ttl, "ttl"); if (ttl < 1 || ttl > 255) { throw ArgumentError('Invalid ttl $ttl'); } @@ -248,8 +244,6 @@ class _InternetAddress implements InternetAddress { String address, { InternetAddressType? type, }) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(address, 'address'); if (type == InternetAddressType.unix) { var rawAddress = FileSystemEntity._toUtf8Array(address); return _InternetAddress( @@ -318,7 +312,6 @@ class _InternetAddress implements InternetAddress { } static _InternetAddress? tryParse(String address) { - checkNotNullable(address, "address"); final parsedAddress = _parseAddressString(address); if (parsedAddress is _InternetAddress) { return parsedAddress; @@ -1417,8 +1410,6 @@ base class _NativeSocket extends _NativeSocketNativeWrapper } } - static int _fixOffset(int? offset) => offset ?? 0; - // This code issues a native write operation. // // On POSIX systems the data will be written using `write` syscall. @@ -1434,8 +1425,6 @@ base class _NativeSocket extends _NativeSocketNativeWrapper // when asynchronous write operation completes and this socket receives // a [writeEvent]. int write(List buffer, int offset, int? bytes) { - // TODO(40614): Remove once non-nullability is sound. - offset = _fixOffset(offset); if (bytes == null) { if (offset > buffer.length) { throw RangeError.value(offset); @@ -1953,8 +1942,6 @@ base class _NativeSocket extends _NativeSocketNativeWrapper dynamic getOption(SocketOption option) { _ensureNotClosingOrClosed(); - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(option, "option"); var result = _nativeGetOption(option._value, address.type._value); if (result is OSError) throw result; return result; @@ -1962,29 +1949,18 @@ base class _NativeSocket extends _NativeSocketNativeWrapper bool setOption(SocketOption option, value) { _ensureNotClosingOrClosed(); - - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(option, "option"); _nativeSetOption(option._value, address.type._value, value); return true; } Uint8List getRawOption(RawSocketOption option) { _ensureNotClosingOrClosed(); - - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(option, "option"); - ArgumentError.checkNotNull(option.value, "option.value"); _nativeGetRawOption(option.level, option.option, option.value); return option.value; } void setRawOption(RawSocketOption option) { _ensureNotClosingOrClosed(); - - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(option, "option"); - ArgumentError.checkNotNull(option.value, "option.value"); _nativeSetRawOption(option.level, option.option, option.value); } diff --git a/sdk/lib/_internal/vm/bin/sync_socket_patch.dart b/sdk/lib/_internal/vm/bin/sync_socket_patch.dart index 42b7dea4e6e..52b237d1584 100644 --- a/sdk/lib/_internal/vm/bin/sync_socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/sync_socket_patch.dart @@ -209,9 +209,6 @@ base class _NativeSynchronousSocket } int readIntoSync(List buffer, int start, int? end) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(buffer, "buffer"); - ArgumentError.checkNotNull(start, "start"); _checkAvailable(); if (isClosedRead) { throw SocketException("Socket is closed for reading"); @@ -290,9 +287,6 @@ base class _NativeSynchronousSocket } void writeFromSync(List buffer, int start, int? end) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(buffer, "buffer"); - ArgumentError.checkNotNull(start, "start"); _checkAvailable(); if (isClosedWrite) { throw SocketException("Socket is closed for writing"); diff --git a/sdk/lib/_internal/vm/lib/async_patch.dart b/sdk/lib/_internal/vm/lib/async_patch.dart index fe4b4be5143..9e1446f30d2 100644 --- a/sdk/lib/_internal/vm/lib/async_patch.dart +++ b/sdk/lib/_internal/vm/lib/async_patch.dart @@ -113,8 +113,6 @@ class _AsyncStarStreamController { } void addError(Object error, StackTrace stackTrace) { - // TODO(40614): Remove once non-nullability is sound. - ArgumentError.checkNotNull(error, "error"); final future = cancellationFuture; if ((future != null) && future._mayComplete) { // If the stream has been cancelled, complete the cancellation future diff --git a/sdk/lib/_internal/vm/lib/string_patch.dart b/sdk/lib/_internal/vm/lib/string_patch.dart index 47d2ea5cd8c..0c95c409f64 100644 --- a/sdk/lib/_internal/vm/lib/string_patch.dart +++ b/sdk/lib/_internal/vm/lib/string_patch.dart @@ -882,10 +882,6 @@ abstract final class _StringBase implements String { static String _interpolateSingle(Object? o) { if (o is String) return o; final s = o.toString(); - // TODO(40614): Remove once non-nullability is sound. - if (s is! String) { - throw _interpolationError(o, s); - } return s; } @@ -908,19 +904,12 @@ abstract final class _StringBase implements String { if (ClassID.getID(s) == ClassID.cidOneByteString) { totalLength += s.length; i++; - } else if (s is! String) { - // TODO(40614): Remove once non-nullability is sound. - throw _interpolationError(e, s); } else { // Handle remaining elements without checking for one-byte-ness. while (++i < numValues) { final e = values[i]; final s = e.toString(); values[i] = s; - // TODO(40614): Remove once non-nullability is sound. - if (s is! String) { - throw _interpolationError(e, s); - } } return _concatRangeNative(values, 0, numValues); } @@ -929,11 +918,6 @@ abstract final class _StringBase implements String { return _OneByteString._concatAll(values, totalLength); } - static ArgumentError _interpolationError(Object? o, Object? result) { - // Since Dart 2.0, [result] can only be null. - return ArgumentError.value(o, "object", "toString method returned 'null'"); - } - Iterable allMatches(String string, [int start = 0]) { if (start < 0 || start > string.length) { throw RangeError.range(start, 0, string.length, "start"); diff --git a/sdk/lib/_internal/vm_shared/lib/bool_patch.dart b/sdk/lib/_internal/vm_shared/lib/bool_patch.dart index 1fa326671c1..d08c10e86fd 100644 --- a/sdk/lib/_internal/vm_shared/lib/bool_patch.dart +++ b/sdk/lib/_internal/vm_shared/lib/bool_patch.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import "dart:_internal" show patch, checkNotNullable; +import "dart:_internal" show patch; @patch @pragma('vm:deeply-immutable') @@ -27,8 +27,6 @@ class bool { @patch static bool parse(String source, {bool caseSensitive = true}) { - checkNotNullable(source, "source"); - checkNotNullable(caseSensitive, "caseSensitive"); if (caseSensitive) { return source == "true" || source != "false" && @@ -42,8 +40,6 @@ class bool { @patch static bool? tryParse(String source, {bool caseSensitive = true}) { - checkNotNullable(source, "source"); - checkNotNullable(caseSensitive, "caseSensitive"); if (caseSensitive) { return source == "true" ? true