Skip to content

Commit 5f9dd43

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: mock SDK: correct declarations in async library
* `Future.catchError`'s and `Stream.handleError`'s _optional_ `test` parameter is nullable. * `Future.whenComplete`'s function-typed parameter has a return type. * Stream is a mixin class. * `Stream.new` is a const constructor. * `Stream.value` has no `@Since` annotation. * `StreamSubscription.cancel`'s return type has a type argument. Change-Id: I301e010732eacb4be4cbf6d43a33275dd70f7c06 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450941 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent b50a115 commit 5f9dd43

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

pkg/analyzer/lib/src/test_utilities/mock_sdk.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ abstract class Future<T> {
3535
throw 0;
3636
}
3737
38-
factory Future.value([FutureOr<T>? result]) {
38+
factory Future.value([FutureOr<T>? value]) {
3939
throw 0;
4040
}
4141
42-
Future<T> catchError(Function onError, {bool test(Object error)});
42+
Future<T> catchError(Function onError, {bool test(Object error)?});
4343
4444
Future<R> then<R>(FutureOr<R> onValue(T value), {Function? onError});
4545
46-
Future<T> whenComplete(action());
46+
Future<T> whenComplete(FutureOr<void> action());
4747
4848
static Future<List<T>> wait<T>(Iterable<Future<T>> futures,
4949
{void cleanUp(T successValue)?}) => throw 0;
@@ -71,7 +71,7 @@ abstract class Timer {
7171
factory Timer(Duration duration, void Function() callback) {
7272
throw 0;
7373
}
74-
static void run(void callback()) {}
74+
static void run(void Function() callback) {}
7575
}
7676
7777
@Since("2.15")
@@ -80,13 +80,12 @@ void unawaited(Future<void>? future) {}
8080
MockSdkLibraryUnit('async/stream.dart', r'''
8181
part of dart.async;
8282
83-
abstract class Stream<T> {
84-
Stream();
85-
factory Stream.fromIterable(Iterable<T> data) {
83+
abstract mixin class Stream<T> {
84+
const Stream();
85+
factory Stream.fromIterable(Iterable<T> elements) {
8686
throw 0;
8787
}
8888
89-
@Since("2.5")
9089
factory Stream.value(T value) {
9190
throw 0;
9291
}
@@ -96,7 +95,7 @@ abstract class Stream<T> {
9695
StreamSubscription<T> listen(void onData(T event)?,
9796
{Function? onError, void onDone()?, bool? cancelOnError});
9897
99-
Stream<T> handleError(Function onError, {bool test(dynamic error)});
98+
Stream<T> handleError(Function onError, {bool test(error)?});
10099
}
101100
102101
abstract class StreamIterator<T> {}
@@ -105,7 +104,7 @@ abstract class StreamSubscription<T> {
105104
bool get isPaused;
106105
107106
Future<E> asFuture<E>([E? futureValue]);
108-
Future cancel();
107+
Future<void> cancel();
109108
void onData(void handleData(T data)?);
110109
void onError(Function? handleError);
111110
void onDone(void handleDone()?);

pkg/analyzer/test/src/dart/resolution/dot_shorthand_constructor_invocation_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ DotShorthandConstructorInvocation
5656
SimpleIdentifier
5757
token: iter
5858
correspondingParameter: ParameterMember
59-
baseElement: dart:async::@class::Stream::@constructor::fromIterable::@formalParameter::data
59+
baseElement: dart:async::@class::Stream::@constructor::fromIterable::@formalParameter::elements
6060
substitution: {T: int}
6161
element: iter@26
6262
staticType: List<int>

0 commit comments

Comments
 (0)