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

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

Issue 1462133005: Downwards inference. This adds support to the resolver for downwards (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments 2 Created 5 years 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 // 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 test.src.task.strong.checker_test; 8 library test.src.task.strong.checker_test;
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 14 matching lines...) Expand all
25 class SplayTreeMap<K, V> { 25 class SplayTreeMap<K, V> {
26 Comparator<K> _comparator; 26 Comparator<K> _comparator;
27 _Predicate _validKey; 27 _Predicate _validKey;
28 28
29 // Initializing _comparator needs a cast, since K may not always be 29 // Initializing _comparator needs a cast, since K may not always be
30 // Comparable. 30 // Comparable.
31 // Initializing _validKey shouldn't need a cast. Currently 31 // Initializing _validKey shouldn't need a cast. Currently
32 // it requires inference to work because of dartbug.com/23381 32 // it requires inference to work because of dartbug.com/23381
33 SplayTreeMap([int compare(K key1, K key2), 33 SplayTreeMap([int compare(K key1, K key2),
34 bool isValidKey(potentialKey)]) { 34 bool isValidKey(potentialKey)]) {
35 : _comparator = /*warning:DownCastComposite*/(compare == null) ? Com parable.compare : compare, 35 : _comparator = /*warning:DownCastComposite*/(compare == null)
36 _validKey = /*info:InferredType should be pass*/(isValidKey != nul l) ? isValidKey : ((v) => true); 36 ? Comparable.compare : compare,
37 _Predicate<Object> _v = /*warning:DownCastComposite*/(isValidKey ! = null) ? isValidKey : ((v) => true); 37 _validKey = /*warning:DownCastComposite*/(isValidKey != null)
38 _v = /*info:InferredType should be pass*/(isValidKey != null) ? _v : ((v) => true); 38 ? isValidKey : ((v) => true);
39 _Predicate<Object> _v = /*warning:DownCastComposite*/(isValidKey != null)
40 ? isValidKey : (/*info:InferredTypeClosure*/ (v) => true);
41 // TODO(leafp): Fix unimplemented LUB in analyzer
42 _v = /*warning:DownCastComposite*/(isValidKey != null)
43 ? _v : (/*info:InferredTypeClosure*/(v) => true);
39 } 44 }
40 } 45 }
41 void main() { 46 void main() {
42 Object obj = 42; 47 Object obj = 42;
43 dynamic dyn = 42; 48 dynamic dyn = 42;
44 int i = 42; 49 int i = 42;
45 50
46 // Check the boolean conversion of the condition. 51 // Check the boolean conversion of the condition.
47 print((/*severe:StaticTypeError*/i) ? false : true); 52 print((/*severe:StaticTypeError*/i) ? false : true);
48 print((/*info:DownCastImplicit*/obj) ? false : true); 53 print((/*info:DownCastImplicit*/obj) ? false : true);
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2404
2400 baz1() sync* { yield* (/*info:DynamicCast*/x); } 2405 baz1() sync* { yield* (/*info:DynamicCast*/x); }
2401 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } 2406 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); }
2402 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } 2407 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); }
2403 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } 2408 Iterable<int> baz4() sync* { yield* new Iterable<int>(); }
2404 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); } 2409 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); }
2405 ''' 2410 '''
2406 }); 2411 });
2407 }); 2412 });
2408 } 2413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698