Skip to content

Commit 0d44449

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Add unawaited to package:meta
Change-Id: I09df4989591327bd4d148e73a5887b900902576c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152680 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Jake Macdonald <[email protected]>
1 parent be0f94b commit 0d44449

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ vars = {
123123
"oauth2_tag": "1.6.0",
124124
"package_config_rev": "9c586d04bd26fef01215fd10e7ab96a3050cfa64",
125125
"path_rev": "4f3bb71843fe5493ba490828a1721821d7b33746",
126-
"pedantic_tag": "v1.9.0",
126+
"pedantic_tag": "v1.9.1",
127127
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
128128
"pool_rev": "86fbb2cde9bbc66c8d159909d2f65a5981ea5b50",
129129
"protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760",

pkg/meta/CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
## 1.2.0-nnbd
1+
## 1.3.0-nnbd
22

33
* Opt into null safety.
4+
5+
## 1.2.1
6+
7+
* Fixed a bug by adding an import of dart:async so that the code really is
8+
compatible with the lower bound of the SDK constraints.
9+
10+
## 1.2.0
11+
412
* Introduce `@doNotStore` to annotate methods, getters and functions to
513
indicate that values obtained by invoking them should not be stored in a
614
field or top-level variable.
15+
* Introduce `unawaited` to mark invocations that return a `Future` where it's
16+
intentional that the future is not being awaited. (Moved from
17+
`package:pedantic`.)
718

819
## 1.1.8
920

pkg/meta/lib/meta.dart

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
1+
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
/// Constants for use in metadata annotations.
5+
/// Constants and functions that developers can use to express the intentions
6+
/// that otherwise can't be deduced by statically analyzing the source code.
67
///
78
/// See also `@deprecated` and `@override` in the `dart:core` library.
89
///
@@ -12,7 +13,7 @@
1213
/// function's name differently.
1314
///
1415
/// For information on installing and importing this library, see the [meta
15-
/// package on pub.dev](https://pub.dev/packages/meta). For examples of using
16+
/// package on pub.dev](https://pub.dev/packages/meta). For examples of using
1617
/// annotations, see
1718
/// [Metadata](https://dart.dev/guides/language/language-tour#metadata) in the
1819
/// language tour.
@@ -266,6 +267,26 @@ const _VisibleForOverriding visibleForOverriding = _VisibleForOverriding();
266267
/// library which is in the `test` folder of the defining package.
267268
const _VisibleForTesting visibleForTesting = _VisibleForTesting();
268269

270+
/// Indicates to tools that [future] is intentionally not `await`-ed.
271+
///
272+
/// In an `async` context, it is normally expected that all [Future]s are
273+
/// awaited, and that is the basis of the lint `unawaited_futures`. However,
274+
/// there are times where one or more futures are intentionally not awaited.
275+
/// This function may be used to ignore a particular future. It silences the
276+
/// `unawaited_futures` lint.
277+
///
278+
/// ```
279+
/// Future<void> saveUserPreferences() async {
280+
/// await _writePreferences();
281+
///
282+
/// // While 'log' returns a Future, the consumer of 'saveUserPreferences'
283+
/// // is unlikely to want to wait for that future to complete; they only
284+
/// // care about the preferences being written).
285+
/// unawaited(log('Preferences saved!'));
286+
/// }
287+
/// ```
288+
void unawaited(Future<void>? future) {}
289+
269290
/// Used to annotate a class.
270291
///
271292
/// See [immutable] for more details.

pkg/meta/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: meta
2-
version: 1.2.0-nnbd
3-
author: Dart Team <[email protected]>
2+
version: 1.3.0-nnbd
43
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/meta
54
description: >
6-
This library contains the definitions of annotations that provide additional
7-
semantic information about the program being annotated. These annotations are
8-
intended to be used by tools to provide a better user experience.
5+
This library contains the declarations of constants and functions that
6+
developers can use to express the intentions that otherwise can't be deduced by
7+
statically analyzing the source code. These declarations are intended to be
8+
used by tools to provide a better user experience.
99
environment:
1010
# This must remain a tight constraint (only allow dev versions) until nnbd is
1111
# stable.

0 commit comments

Comments
 (0)