mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:10:22 +00:00
[lib] Add null check of types back into _Invocation.method
Until everyone is opted in to NNBD, we still need null checks in the libs. This fixes corelib_2/invocation_test This check was removed in https://dart-review.googlesource.com/c/sdk/+/123621 Change-Id: I645e8c03883bee2d5a52f1b6d19789177411199c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135220 Commit-Queue: Liam Appelbe <liama@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Régis Crelier <regis@google.com>
This commit is contained in:
parent
b9fbf58e33
commit
89dc08efe7
1 changed files with 14 additions and 2 deletions
|
@ -118,8 +118,7 @@ class _Invocation implements Invocation {
|
|||
|
||||
_Invocation.method(this.memberName, Iterable<Type>? types,
|
||||
Iterable<Object?>? positional, Map<Symbol, Object?>? named)
|
||||
: typeArguments =
|
||||
types == null ? const <Type>[] : List<Type>.unmodifiable(types),
|
||||
: typeArguments = _ensureNonNullTypes(types),
|
||||
_positional = positional == null
|
||||
? const <Object?>[]
|
||||
: List<Object?>.unmodifiable(positional),
|
||||
|
@ -145,4 +144,17 @@ class _Invocation implements Invocation {
|
|||
bool get isGetter => _positional == null;
|
||||
bool get isSetter => _positional != null && _named == null;
|
||||
bool get isAccessor => _named == null;
|
||||
|
||||
/// Checks that the elements of [types] are not null.
|
||||
static List<Type> _ensureNonNullTypes(Iterable<Type>? types) {
|
||||
if (types == null) return const <Type>[];
|
||||
List<Type> typeArguments = List<Type>.unmodifiable(types);
|
||||
for (int i = 0; i < typeArguments.length; i++) {
|
||||
if (typeArguments[i] == null) {
|
||||
throw ArgumentError.value(types, "types",
|
||||
"Type arguments must be non-null, was null at index $i.");
|
||||
}
|
||||
}
|
||||
return typeArguments;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue