Skip to content

Commit

Permalink
Add unawaited to package:meta
Browse files Browse the repository at this point in the history
Change-Id: I09df4989591327bd4d148e73a5887b900902576c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152680
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
  • Loading branch information
bwilkerson authored and commit-bot@chromium.org committed Jul 6, 2020
1 parent be0f94b commit 0d44449
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ vars = {
"oauth2_tag": "1.6.0",
"package_config_rev": "9c586d04bd26fef01215fd10e7ab96a3050cfa64",
"path_rev": "4f3bb71843fe5493ba490828a1721821d7b33746",
"pedantic_tag": "v1.9.0",
"pedantic_tag": "v1.9.1",
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_rev": "86fbb2cde9bbc66c8d159909d2f65a5981ea5b50",
"protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760",
Expand Down
13 changes: 12 additions & 1 deletion pkg/meta/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
## 1.2.0-nnbd
## 1.3.0-nnbd

* Opt into null safety.

## 1.2.1

* Fixed a bug by adding an import of dart:async so that the code really is
compatible with the lower bound of the SDK constraints.

## 1.2.0

* Introduce `@doNotStore` to annotate methods, getters and functions to
indicate that values obtained by invoking them should not be stored in a
field or top-level variable.
* Introduce `unawaited` to mark invocations that return a `Future` where it's
intentional that the future is not being awaited. (Moved from
`package:pedantic`.)

## 1.1.8

Expand Down
27 changes: 24 additions & 3 deletions pkg/meta/lib/meta.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// 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.

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

/// Indicates to tools that [future] is intentionally not `await`-ed.
///
/// In an `async` context, it is normally expected that all [Future]s are
/// awaited, and that is the basis of the lint `unawaited_futures`. However,
/// there are times where one or more futures are intentionally not awaited.
/// This function may be used to ignore a particular future. It silences the
/// `unawaited_futures` lint.
///
/// ```
/// Future<void> saveUserPreferences() async {
/// await _writePreferences();
///
/// // While 'log' returns a Future, the consumer of 'saveUserPreferences'
/// // is unlikely to want to wait for that future to complete; they only
/// // care about the preferences being written).
/// unawaited(log('Preferences saved!'));
/// }
/// ```
void unawaited(Future<void>? future) {}

/// Used to annotate a class.
///
/// See [immutable] for more details.
Expand Down
10 changes: 5 additions & 5 deletions pkg/meta/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: meta
version: 1.2.0-nnbd
author: Dart Team <misc@dartlang.org>
version: 1.3.0-nnbd
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/meta
description: >
This library contains the definitions of annotations that provide additional
semantic information about the program being annotated. These annotations are
intended to be used by tools to provide a better user experience.
This library contains the declarations of constants and functions that
developers can use to express the intentions that otherwise can't be deduced by
statically analyzing the source code. These declarations are intended to be
used by tools to provide a better user experience.
environment:
# This must remain a tight constraint (only allow dev versions) until nnbd is
# stable.
Expand Down

0 comments on commit 0d44449

Please sign in to comment.