Skip to content

Commit afbb8f9

Browse files
srawlinscommit-bot@chromium.org
authored andcommitted
Meta: introduce @internal annotation
Fixes #28066 Change-Id: I200173e48bfbffa8460d6273c274d210b3be8606 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164244 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent fdf4a1c commit afbb8f9

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

pkg/meta/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.3.0-nullsafety.4
2+
3+
* Introduce `@internal` to annotate elements that should not be used outside of
4+
the package in which the element is declared.
5+
16
## 1.3.0-nullsafety.3
27

38
* Allow 2.10 stable and 2.11.0 dev SDK versions.

pkg/meta/lib/meta.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ const _Factory factory = _Factory();
126126
/// class that has this annotation is not immutable.
127127
const Immutable immutable = Immutable();
128128

129+
/// Used to annotate a declaration which should only be used from within the
130+
/// package in which it is declared, and which should not be exposed from said
131+
/// package's public API.
132+
///
133+
/// Tools, such as the analyzer, can provide feedback if
134+
///
135+
/// * the declaration is declared in a package's public API, or is exposed from
136+
/// a package's public API, or
137+
/// * the declaration is private, an unnamed extension, a static member of a
138+
/// private class, mixin, or extension, a value of a private enum, or a
139+
/// constructor of a private class, or
140+
/// * the declaration is referenced outside the package in which it is declared.
141+
const _Internal internal = _Internal();
142+
129143
/// Used to annotate a test framework function that runs a single test.
130144
///
131145
/// Tools, such as IDEs, can show invocations of such function in a file
@@ -257,15 +271,15 @@ const _Virtual virtual = _Virtual();
257271
/// * the member is referenced outside of the defining library.
258272
const _VisibleForOverriding visibleForOverriding = _VisibleForOverriding();
259273

260-
/// Used to annotate a declaration was made public, so that it is more visible
261-
/// than otherwise necessary, to make code testable.
274+
/// Used to annotate a declaration that was made public, so that it is more
275+
/// visible than otherwise necessary, to make code testable.
262276
///
263277
/// Tools, such as the analyzer, can provide feedback if
264278
///
265279
/// * the annotation is associated with a declaration not in the `lib` folder
266280
/// of a package, or a private declaration, or a declaration in an unnamed
267281
/// static extension, or
268-
/// * the declaration is referenced outside of its the defining library or a
282+
/// * the declaration is referenced outside of its defining library or a
269283
/// library which is in the `test` folder of the defining package.
270284
const _VisibleForTesting visibleForTesting = _VisibleForTesting();
271285

@@ -326,6 +340,10 @@ class _Factory {
326340
const _Factory();
327341
}
328342

343+
class _Internal {
344+
const _Internal();
345+
}
346+
329347
class _IsTest {
330348
const _IsTest();
331349
}

0 commit comments

Comments
 (0)