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

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

Issue 1807213005: Use GLB for function parameters when doing LUB in strong mode. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix summary tests that are doing the right thing now. Created 4 years, 9 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/src/summary/summary_common.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 10 matching lines...) Expand all
21 static int compare(Comparable a, Comparable b) => a.compareTo(b); 21 static int compare(Comparable a, Comparable b) => a.compareTo(b);
22 } 22 }
23 typedef int Comparator<T>(T a, T b); 23 typedef int Comparator<T>(T a, T b);
24 24
25 typedef bool _Predicate<T>(T value); 25 typedef bool _Predicate<T>(T value);
26 26
27 class SplayTreeMap<K, V> { 27 class SplayTreeMap<K, V> {
28 Comparator<K> _comparator; 28 Comparator<K> _comparator;
29 _Predicate _validKey; 29 _Predicate _validKey;
30 30
31 // TODO(rnystrom): Initializing _comparator should have a cast, since 31 // The warning on assigning to _comparator is legitimate. Since K has
32 // K may not always be Comparable. It doesn't currently get one 32 // no bound, all we know is that it's object. _comparator's function
33 // because we're using the spec's LUB on function types, which isn't 33 // type is effectively: (Object, Object) -> int
34 // sound. 34 // We are assigning it a fn of type: (Comparable, Comparable) -> int
35 // There's no telling if that will work. For example, consider:
36 //
37 // new SplayTreeMap<Uri>();
38 //
39 // This would end up calling .compareTo() on a Uri, which doesn't
40 // define that since it doesn't implement Comparable.
35 SplayTreeMap([int compare(K key1, K key2), 41 SplayTreeMap([int compare(K key1, K key2),
36 bool isValidKey(potentialKey)]) 42 bool isValidKey(potentialKey)])
37 : _comparator = (compare == null) ? Comparable.compare : compare, 43 : _comparator = /*warning:DOWN_CAST_COMPOSITE*/(compare == null) ? C omparable.compare : compare,
38 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) { 44 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) {
39 _Predicate<Object> v = /*warning:DOWN_CAST_COMPOSITE*/(isValidKey != null) 45 _Predicate<Object> v = (isValidKey != null)
40 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE */(_) => true); 46 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
41 47
42 v = (isValidKey != null) 48 v = (isValidKey != null)
43 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); 49 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
44 } 50 }
45 } 51 }
46 void main() { 52 void main() {
47 Object obj = 42; 53 Object obj = 42;
48 dynamic dyn = 42; 54 dynamic dyn = 42;
49 int i = 42; 55 int i = 42;
50 56
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 2979
2974 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } 2980 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; }
2975 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } 2981 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; }
2976 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } 2982 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; }
2977 Iterable<int> baz4() sync* { yield* bar3(); } 2983 Iterable<int> baz4() sync* { yield* bar3(); }
2978 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); } 2984 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new List(); }
2979 '''); 2985 ''');
2980 }); 2986 });
2981 }); 2987 });
2982 } 2988 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/summary_common.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698