Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: test/rules/always_specify_types.dart

Issue 1880953004: Fix to respect `@optionalTypeArgs` (#196). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5
6 // Hack to work around issues importing `meta.dart` in tests.
7 // Ideally, remove:
8 library meta;
9
10 class _OptionalTypeArgs {
11 const _OptionalTypeArgs();
12 }
13
14 const _OptionalTypeArgs optionalTypeArgs = const _OptionalTypeArgs();
15
16 // ... and replace w/:
17 // import 'package:meta/meta.dart';
18
5 List list; // LINT 19 List list; // LINT
6 List<List> lists; //LINT 20 List<List> lists; //LINT
7 List<int> ints; //OK 21 List<int> ints; //OK
8 22
9 final x = 1; //LINT [1:5] 23 final x = 1; //LINT [1:5]
10 final int xx = 3; 24 final int xx = 3;
11 const y = 2; //LINT 25 const y = 2; //LINT
12 const int yy = 3; 26 const int yy = 3;
13 27
14 a(var x) {} //LINT 28 a(var x) {} //LINT
15 b(s) {} //LINT [3:1] 29 b(s) {} //LINT [3:1]
16 c(int x) {} 30 c(int x) {}
17 d(final x) {} //LINT 31 d(final x) {} //LINT
18 e(final int x) {} 32 e(final int x) {}
19 33
34 @optionalTypeArgs
35 class P<T> { }
36
20 main() { 37 main() {
21 var x = ''; //LINT [3:3] 38 var x = ''; //LINT [3:3]
22 for (var i = 0; i < 10; ++i) { //LINT [8:3] 39 for (var i = 0; i < 10; ++i) { //LINT [8:3]
23 print(i); 40 print(i);
24 } 41 }
25 List<String> ls = <String>[]; 42 List<String> ls = <String>[];
26 ls.forEach((s) => print(s)); //LINT [15:1] 43 ls.forEach((s) => print(s)); //LINT [15:1]
27 for (var l in ls) { //LINT [8:3] 44 for (var l in ls) { //LINT [8:3]
28 print(l); 45 print(l);
29 } 46 }
30 try { 47 try {
31 for (final l in ls) { // LINT [10:5] 48 for (final l in ls) { // LINT [10:5]
32 print(l); 49 print(l);
33 } 50 }
34 } on Exception catch (ex) { 51 } on Exception catch (ex) {
35 print(ex); 52 print(ex);
36 } catch (e) { // NO warning (https://codereview.chromium.org/1427223002/) 53 } catch (e) { // NO warning (https://codereview.chromium.org/1427223002/)
37 print(e); 54 print(e);
38 } 55 }
39 56
40 var __; // LINT 57 var __; // LINT
41 58
42 listen((_) { // OK! 59 listen((_) { // OK!
43 // ... 60 // ...
44 }); 61 });
62
63 P p = new P(); //OK (optionalTypeArgs)
64 }
65
66 P doSomething(P p) //OK (optionalTypeArgs)
67 {
68 return p;
45 } 69 }
46 70
47 listen(void onData(Object event)) {} 71 listen(void onData(Object event)) {}
48 72
49 var z; //LINT 73 var z; //LINT
50 74
51 class Foo { 75 class Foo {
52 static var bar; //LINT 76 static var bar; //LINT
53 static final baz = 1; //LINT 77 static final baz = 1; //LINT
54 static final int bazz = 42; 78 static final int bazz = 42;
55 var foo; //LINT 79 var foo; //LINT
56 Foo(var bar); //LINT [7:3] 80 Foo(var bar); //LINT [7:3]
57 void f(List l) { } //LINT 81 void f(List l) { } //LINT
58 } 82 }
59 83
OLDNEW
« lib/src/rules/always_specify_types.dart ('K') | « lib/src/rules/always_specify_types.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698