[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 <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Alexander Markov
2025-12-16 15:07:39 -08:00
committed by Commit Queue
parent 3fbd3ab070
commit ecf78ee1ae
8 changed files with 3 additions and 67 deletions
@@ -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) \
+1 -1
View File
@@ -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
@@ -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);
@@ -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<int> 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);
}
@@ -209,9 +209,6 @@ base class _NativeSynchronousSocket
}
int readIntoSync(List<int> 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<int> 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");
@@ -113,8 +113,6 @@ class _AsyncStarStreamController<T> {
}
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
@@ -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<Match> allMatches(String string, [int start = 0]) {
if (start < 0 || start > string.length) {
throw RangeError.range(start, 0, string.length, "start");
@@ -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