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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/task/strong/checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index 09738bd19cc465d46b5df8ec364984d366c1ef7a..9cda69e7e0fb3ceea9e0865f9ca6f09055a53a17 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -28,16 +28,22 @@ void main() {
Comparator<K> _comparator;
_Predicate _validKey;
- // TODO(rnystrom): Initializing _comparator should have a cast, since
- // K may not always be Comparable. It doesn't currently get one
- // because we're using the spec's LUB on function types, which isn't
- // sound.
+ // The warning on assigning to _comparator is legitimate. Since K has
+ // no bound, all we know is that it's object. _comparator's function
+ // type is effectively: (Object, Object) -> int
+ // We are assigning it a fn of type: (Comparable, Comparable) -> int
+ // There's no telling if that will work. For example, consider:
+ //
+ // new SplayTreeMap<Uri>();
+ //
+ // This would end up calling .compareTo() on a Uri, which doesn't
+ // define that since it doesn't implement Comparable.
SplayTreeMap([int compare(K key1, K key2),
bool isValidKey(potentialKey)])
- : _comparator = (compare == null) ? Comparable.compare : compare,
+ : _comparator = /*warning:FIELD_INITIALIZER_NOT_ASSIGNABLE*/(compare == null) ? Comparable.compare : compare,
_validKey = (isValidKey != null) ? isValidKey : ((v) => true) {
- _Predicate<Object> v = /*warning:DOWN_CAST_COMPOSITE*/(isValidKey != null)
Leaf 2016/03/22 00:02:20 \o/
- ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
+ _Predicate<Object> v = (isValidKey != null)
+ ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
v = (isValidKey != null)
? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);

Powered by Google App Engine
This is Rietveld 408576698