Skip to content

Commit 537a6f1

Browse files
srawlinscommit-bot@chromium.org
authored andcommitted
Introduce @Sealed annotation
This annotation will act as an easy way for users to experiment with a language feature under consideration, called "sealed classes." Bug: #27372 Change-Id: Ieb8bc70edaf8c11c41f0f47c01951e8311736c1f Reviewed-on: https://dart-review.googlesource.com/69601 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Lasse R.H. Nielsen <[email protected]> Reviewed-by: Erik Ernst <[email protected]> Reviewed-by: Leaf Petersen <[email protected]>
1 parent 40d72ae commit 537a6f1

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

pkg/meta/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.1.7
2+
3+
* Introduce `@sealed` to declare that a class cannot be extended by, implemented
4+
by, or mixed into another class. (SDK issue
5+
[27372](https://github.com/dart-lang/sdk/issues/27372)).
6+
17
## 1.1.6
28

39
* Set max SDK version to <3.0.0.

pkg/meta/lib/meta.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ const _Protected protected = const _Protected();
188188
/// corresponding to a named parameter that has this annotation.
189189
const Required required = const Required();
190190

191+
/// Annotation marking a class as unusable as a super-type, outside of the
192+
/// package in which the class is declared.
193+
///
194+
/// Given a class _C_, which is annotated with this, and a class _D_, which
195+
/// extends, implements, or mixes in _C_, then tools, such as the analyzer, may
196+
/// emit warnings if:
197+
///
198+
/// * _C_ and _D_ are declared in different packages, or
199+
/// * _C_ and _D_ are declared in the same package, and _D_ is not also
200+
/// annotated with this.
201+
const _Sealed sealed = const _Sealed();
202+
191203
/// Used to annotate a field that is allowed to be overridden in Strong Mode.
192204
const _Virtual virtual = const _Virtual();
193205

@@ -284,6 +296,10 @@ class _Protected {
284296
const _Protected();
285297
}
286298

299+
class _Sealed {
300+
const _Sealed();
301+
}
302+
287303
class _Virtual {
288304
const _Virtual();
289305
}

pkg/meta/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: meta
2-
version: 1.1.6
2+
version: 1.1.7
33
author: Dart Team <[email protected]>
44
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/meta
55
description: >

0 commit comments

Comments
 (0)