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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 1827243003: Allow values to be returned from implicitly typed setters (Closed) Base URL: git@github.com:dart-lang/sdk.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
« no previous file with comments | « pkg/analyzer/test/generated/strong_mode_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 /// General type checking tests 7 /// General type checking tests
8 library analyzer.test.src.task.strong.checker_test; 8 library analyzer.test.src.task.strong.checker_test;
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 int i = 42; 55 int i = 42;
56 56
57 // Check the boolean conversion of the condition. 57 // Check the boolean conversion of the condition.
58 print(/*warning:NON_BOOL_CONDITION*/i ? false : true); 58 print(/*warning:NON_BOOL_CONDITION*/i ? false : true);
59 print((/*info:DOWN_CAST_IMPLICIT*/obj) ? false : true); 59 print((/*info:DOWN_CAST_IMPLICIT*/obj) ? false : true);
60 print((/*info:DYNAMIC_CAST*/dyn) ? false : true); 60 print((/*info:DYNAMIC_CAST*/dyn) ? false : true);
61 } 61 }
62 '''); 62 ''');
63 }); 63 });
64 64
65 test('setter return types', () {
66 checkFile('''
67 void voidFn() => null;
68 class A {
69 set a(y) => 4;
70 set b(y) => voidFn();
71 void set c(y) => /*warning:RETURN_OF_INVALID_TYPE*/4;
72 void set d(y) => voidFn();
73 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4;
74 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) => /*warning:RETURN_O F_INVALID_TYPE*/voidFn();
75 set g(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;}
76 void set h(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;}
77 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;}
78 }
79 ''');
80
81 });
82
65 test('if/for/do/while statements use boolean conversion', () { 83 test('if/for/do/while statements use boolean conversion', () {
66 checkFile(''' 84 checkFile('''
67 main() { 85 main() {
68 dynamic dyn = 42; 86 dynamic dyn = 42;
69 Object obj = 42; 87 Object obj = 42;
70 int i = 42; 88 int i = 42;
71 bool b = false; 89 bool b = false;
72 90
73 if (b) {} 91 if (b) {}
74 if (/*info:DYNAMIC_CAST*/dyn) {} 92 if (/*info:DYNAMIC_CAST*/dyn) {}
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 2997
2980 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } 2998 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; }
2981 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } 2999 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; }
2982 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } 3000 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; }
2983 Iterable<int> baz4() sync* { yield* bar3(); } 3001 Iterable<int> baz4() sync* { yield* bar3(); }
2984 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); } 3002 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); }
2985 '''); 3003 ''');
2986 }); 3004 });
2987 }); 3005 });
2988 } 3006 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/strong_mode_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698