File tree 7 files changed +44
-0
lines changed
analysis_server/test/mock_packages/meta/lib
7 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ class _NonVirtual {
518
518
@Target ({
519
519
TargetKind .classType,
520
520
TargetKind .extension ,
521
+ TargetKind .extensionType,
521
522
TargetKind .function,
522
523
TargetKind .method,
523
524
TargetKind .mixinType,
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class TargetKind {
39
39
/// Indicates that an annotation is valid on any extension declaration.
40
40
static const extension = TargetKind ._('extensions' , 'extension' );
41
41
42
+ /// Indicates that an annotation is valid on any extension type declaration.
43
+ static const extensionType = TargetKind ._('extension types' , 'extensionType' );
44
+
42
45
/// Indicates that an annotation is valid on any field declaration, both
43
46
/// instance and static fields, whether it's in a class, mixin or extension.
44
47
static const field = TargetKind ._('fields' , 'field' );
@@ -91,6 +94,7 @@ class TargetKind {
91
94
classType,
92
95
enumType,
93
96
extension ,
97
+ extensionType,
94
98
field,
95
99
function,
96
100
library,
Original file line number Diff line number Diff line change @@ -554,6 +554,8 @@ class AnnotationVerifier {
554
554
} else if (target is EnumDeclaration ) {
555
555
return kinds.contains (TargetKind .enumType) ||
556
556
kinds.contains (TargetKind .type);
557
+ } else if (target is ExtensionTypeDeclaration ) {
558
+ return kinds.contains (TargetKind .extensionType);
557
559
} else if (target is ExtensionDeclaration ) {
558
560
return kinds.contains (TargetKind .extension );
559
561
} else if (target is FieldDeclaration ) {
Original file line number Diff line number Diff line change @@ -238,6 +238,7 @@ class _NonVirtual {
238
238
@Target({
239
239
TargetKind.classType,
240
240
TargetKind.extension,
241
+ TargetKind.extensionType,
241
242
TargetKind.function,
242
243
TargetKind.method,
243
244
TargetKind.mixinType,
@@ -284,6 +285,7 @@ class TargetKind {
284
285
static const classType = TargetKind._('classes', 'classType');
285
286
static const enumType = TargetKind._('enums', 'enumType');
286
287
static const extension = TargetKind._('extensions', 'extension');
288
+ static const extensionType = TargetKind._('extension types', 'extensionType');
287
289
static const field = TargetKind._('fields', 'field');
288
290
static const function = TargetKind._('top-level functions', 'function');
289
291
static const library = TargetKind._('libraries', 'library');
@@ -302,6 +304,7 @@ class TargetKind {
302
304
classType,
303
305
enumType,
304
306
extension,
307
+ extensionType,
305
308
field,
306
309
function,
307
310
library,
Original file line number Diff line number Diff line change @@ -14,9 +14,38 @@ main() {
14
14
15
15
@reflectiveTest
16
16
class AlwaysSpecifyTypesTest extends LintRuleTest {
17
+ @override
18
+ bool get addMetaPackageDep => true ;
19
+
17
20
@override
18
21
String get lintRule => 'always_specify_types' ;
19
22
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
+
20
49
test_listPattern_destructured () async {
21
50
await assertDiagnostics (r'''
22
51
f() {
Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ class _NonVirtual {
518
518
@Target ({
519
519
TargetKind .classType,
520
520
TargetKind .extension ,
521
+ TargetKind .extensionType,
521
522
TargetKind .function,
522
523
TargetKind .method,
523
524
TargetKind .mixinType,
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ class TargetKind {
39
39
/// Indicates that an annotation is valid on any extension declaration.
40
40
static const extension = TargetKind ._('extensions' , 'extension' );
41
41
42
+ /// Indicates that an annotation is valid on any extension type declaration.
43
+ static const extensionType = TargetKind ._('extension types' , 'extensionType' );
44
+
42
45
/// Indicates that an annotation is valid on any field declaration, both
43
46
/// instance and static fields, whether it's in a class, mixin or extension.
44
47
static const field = TargetKind ._('fields' , 'field' );
@@ -91,6 +94,7 @@ class TargetKind {
91
94
classType,
92
95
enumType,
93
96
extension ,
97
+ extensionType,
94
98
field,
95
99
function,
96
100
library,
You can’t perform that action at this time.
0 commit comments