File tree Expand file tree Collapse file tree 7 files changed +44
-0
lines changed
analysis_server/test/mock_packages/meta/lib Expand file tree Collapse file tree 7 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ class _NonVirtual {
518518@Target ({
519519 TargetKind .classType,
520520 TargetKind .extension ,
521+ TargetKind .extensionType,
521522 TargetKind .function,
522523 TargetKind .method,
523524 TargetKind .mixinType,
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class TargetKind {
3939 /// Indicates that an annotation is valid on any extension declaration.
4040 static const extension = TargetKind ._('extensions' , 'extension' );
4141
42+ /// Indicates that an annotation is valid on any extension type declaration.
43+ static const extensionType = TargetKind ._('extension types' , 'extensionType' );
44+
4245 /// Indicates that an annotation is valid on any field declaration, both
4346 /// instance and static fields, whether it's in a class, mixin or extension.
4447 static const field = TargetKind ._('fields' , 'field' );
@@ -91,6 +94,7 @@ class TargetKind {
9194 classType,
9295 enumType,
9396 extension ,
97+ extensionType,
9498 field,
9599 function,
96100 library,
Original file line number Diff line number Diff line change @@ -554,6 +554,8 @@ class AnnotationVerifier {
554554 } else if (target is EnumDeclaration ) {
555555 return kinds.contains (TargetKind .enumType) ||
556556 kinds.contains (TargetKind .type);
557+ } else if (target is ExtensionTypeDeclaration ) {
558+ return kinds.contains (TargetKind .extensionType);
557559 } else if (target is ExtensionDeclaration ) {
558560 return kinds.contains (TargetKind .extension );
559561 } else if (target is FieldDeclaration ) {
Original file line number Diff line number Diff line change @@ -238,6 +238,7 @@ class _NonVirtual {
238238@Target({
239239 TargetKind.classType,
240240 TargetKind.extension,
241+ TargetKind.extensionType,
241242 TargetKind.function,
242243 TargetKind.method,
243244 TargetKind.mixinType,
@@ -284,6 +285,7 @@ class TargetKind {
284285 static const classType = TargetKind._('classes', 'classType');
285286 static const enumType = TargetKind._('enums', 'enumType');
286287 static const extension = TargetKind._('extensions', 'extension');
288+ static const extensionType = TargetKind._('extension types', 'extensionType');
287289 static const field = TargetKind._('fields', 'field');
288290 static const function = TargetKind._('top-level functions', 'function');
289291 static const library = TargetKind._('libraries', 'library');
@@ -302,6 +304,7 @@ class TargetKind {
302304 classType,
303305 enumType,
304306 extension,
307+ extensionType,
305308 field,
306309 function,
307310 library,
Original file line number Diff line number Diff line change @@ -14,9 +14,38 @@ main() {
1414
1515@reflectiveTest
1616class AlwaysSpecifyTypesTest extends LintRuleTest {
17+ @override
18+ bool get addMetaPackageDep => true ;
19+
1720 @override
1821 String get lintRule => 'always_specify_types' ;
1922
23+ test_extensionType_optionalTypeArgs () async {
24+ await assertNoDiagnostics (r'''
25+ import 'package:meta/meta.dart';
26+
27+ @optionalTypeArgs
28+ extension type E<T>(int i) { }
29+
30+ void f() {
31+ E e = E(1);
32+ }
33+ ''' );
34+ }
35+
36+ test_extensionType_typeArgs () async {
37+ await assertDiagnostics (r'''
38+ extension type E<T>(int i) { }
39+
40+ void f() {
41+ E e = E(1);
42+ }
43+ ''' , [
44+ lint (45 , 1 ),
45+ lint (51 , 1 ),
46+ ]);
47+ }
48+
2049 test_listPattern_destructured () async {
2150 await assertDiagnostics (r'''
2251f() {
Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ class _NonVirtual {
518518@Target ({
519519 TargetKind .classType,
520520 TargetKind .extension ,
521+ TargetKind .extensionType,
521522 TargetKind .function,
522523 TargetKind .method,
523524 TargetKind .mixinType,
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class TargetKind {
3939 /// Indicates that an annotation is valid on any extension declaration.
4040 static const extension = TargetKind ._('extensions' , 'extension' );
4141
42+ /// Indicates that an annotation is valid on any extension type declaration.
43+ static const extensionType = TargetKind ._('extension types' , 'extensionType' );
44+
4245 /// Indicates that an annotation is valid on any field declaration, both
4346 /// instance and static fields, whether it's in a class, mixin or extension.
4447 static const field = TargetKind ._('fields' , 'field' );
@@ -91,6 +94,7 @@ class TargetKind {
9194 classType,
9295 enumType,
9396 extension ,
97+ extensionType,
9498 field,
9599 function,
96100 library,
You can’t perform that action at this time.
0 commit comments