Migrate package:dart_internal to null safety.

This also highlighted a couple of mistakes in the patch files for

dart:_internal and the test.
Change-Id: I60b4e7d5673d64f85a95108c9e03f9328249b9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153021
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom 2020-08-17 23:06:35 +00:00 committed by commit-bot@chromium.org
parent 538e2e4778
commit 5be77279cd
6 changed files with 13 additions and 11 deletions

View file

@ -11,7 +11,7 @@
"constraint, update this by running tools/generate_package_config.dart."
],
"configVersion": 2,
"generated": "2020-08-13T10:20:32.864803",
"generated": "2020-08-17T14:05:33.104579",
"generator": "tools/generate_package_config.dart",
"packages": [
{
@ -202,7 +202,7 @@
"name": "dart_internal",
"rootUri": "../pkg/dart_internal",
"packageUri": "lib/",
"languageVersion": "2.0"
"languageVersion": "2.10"
},
{
"name": "dart_style",

View file

@ -22,8 +22,8 @@ import 'dart:_internal' as internal;
/// print(extractIterableTypeArgument(iterable, <T>() => new Set<T>());
/// // Prints "Instance of 'Set<int>'".
/// ```
Object extractIterableTypeArgument(
Iterable iterable, Object Function<T>() extract) =>
Object? extractIterableTypeArgument(
Iterable iterable, Object? Function<T>() extract) =>
internal.extractTypeArguments<Iterable>(iterable, extract);
/// Given a [Map], invokes [extract], passing the [map]'s key and value type
@ -40,5 +40,5 @@ Object extractIterableTypeArgument(
/// // Prints "Instance of 'Two<String, int>'".
/// }
/// ```
Object extractMapTypeArguments(Map map, Object Function<K, V>() extract) =>
Object? extractMapTypeArguments(Map map, Object? Function<K, V>() extract) =>
internal.extractTypeArguments<Map>(map, extract);

View file

@ -1,5 +1,7 @@
name: dart_internal
version: 0.1.10
version: 0.1.11-nullsafety
author: "Dart Team <misc@dartlang.org>"
homepage: http://www.dartlang.org
repository: https://github.com/dart-lang/sdk/tree/master/pkg/dart_internal
description: >
This package is not intended for wide use. It provides a temporary API to
@ -16,4 +18,4 @@ description: >
environment:
# Restrict the upper bound so that we can remove support for this in a later
# version of the SDK without it being a breaking change.
sdk: ">=2.0.0 <2.10.0"
sdk: ">=2.10.0-0.0 <2.10.0"

View file

@ -57,7 +57,7 @@ List<T> makeFixedListUnmodifiable<T>(List<T> fixedLengthList) {
@patch
@pragma('dart2js:noInline')
Object extractTypeArguments<T>(T instance, Function extract) {
Object? extractTypeArguments<T>(T instance, Function extract) {
// This function is recognized and replaced with calls to js_runtime.
// This call to [extract] is required to model that the function is called and

View file

@ -32,7 +32,7 @@ List<T> makeFixedListUnmodifiable<T>(List<T> fixedLengthList)
native "Internal_makeFixedListUnmodifiable";
@patch
Object extractTypeArguments<T>(T instance, Function extract)
Object? extractTypeArguments<T>(T instance, Function extract)
native "Internal_extractTypeArguments";
/// The returned string is a [_OneByteString] with uninitialized content.

View file

@ -39,7 +39,7 @@ testExtractIterableTypeArgument() {
Expect.isTrue(called);
// Returns result of function.
Object result = extractIterableTypeArgument(object, <T>() => new Set<T>());
Object? result = extractIterableTypeArgument(object, <T>() => new Set<T>());
Expect.isTrue(result is Set<int>);
Expect.isFalse(result is Set<bool>);
@ -63,7 +63,7 @@ testExtractMapTypeArguments() {
Expect.isTrue(called);
// Returns result of function.
Object result = extractMapTypeArguments(object, <K, V>() => new Two<K, V>());
Object? result = extractMapTypeArguments(object, <K, V>() => new Two<K, V>());
Expect.isTrue(result is Two<String, int>);
Expect.isFalse(result is Two<int, String>);