Fix analyzer warnings in the YAML package.
R=rnystrom@google.com
Review URL: https://codereview.chromium.org//277593005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/yaml@35939 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/yaml/lib/src/deep_equals.dart b/pkgs/yaml/lib/src/deep_equals.dart
index bce4aad..1e1f7ed 100644
--- a/pkgs/yaml/lib/src/deep_equals.dart
+++ b/pkgs/yaml/lib/src/deep_equals.dart
@@ -4,8 +4,10 @@
library deep_equals;
-/// Returns whether two objects are structurally equivalent. This considers NaN
-/// values to be equivalent. It also handles self-referential structures.
+/// Returns whether two objects are structurally equivalent.
+///
+/// This considers `NaN` values to be equivalent. It also handles
+/// self-referential structures.
bool deepEquals(obj1, obj2, [List parents1, List parents2]) {
if (identical(obj1, obj2)) return true;
if (parents1 == null) {
@@ -30,8 +32,8 @@
return _listEquals(obj1, obj2, parents1, parents2);
} else if (obj1 is Map && obj2 is Map) {
return _mapEquals(obj1, obj2, parents1, parents2);
- } else if (obj1 is double && obj2 is double) {
- return _doubleEquals(obj1, obj2);
+ } else if (obj1 is num && obj2 is num) {
+ return _numEquals(obj1, obj2);
} else {
return obj1 == obj2;
}
@@ -64,9 +66,11 @@
return true;
}
-/// Returns whether two doubles are equivalent. This differs from `d1 == d2` in
-/// that it considers NaN to be equal to itself.
-bool _doubleEquals(double d1, double d2) {
- if (d1.isNaN && d2.isNaN) return true;
- return d1 == d2;
+/// Returns whether two numbers are equivalent.
+///
+/// This differs from `n1 == n2` in that it considers `NaN` to be equal to
+/// itself.
+bool _numEquals(num n1, num n2) {
+ if (n1.isNaN && n2.isNaN) return true;
+ return n1 == n2;
}
diff --git a/pkgs/yaml/lib/src/parser.dart b/pkgs/yaml/lib/src/parser.dart
index 2616038..162fef4 100644
--- a/pkgs/yaml/lib/src/parser.dart
+++ b/pkgs/yaml/lib/src/parser.dart
@@ -1106,13 +1106,14 @@
// 136
int inFlow(int ctx) {
switch (ctx) {
- case FLOW_OUT:
- case FLOW_IN:
- return FLOW_IN;
- case BLOCK_KEY:
- case FLOW_KEY:
- return FLOW_KEY;
+ case FLOW_OUT:
+ case FLOW_IN:
+ return FLOW_IN;
+ case BLOCK_KEY:
+ case FLOW_KEY:
+ return FLOW_KEY;
}
+ throw "unreachable";
}
// 137
@@ -1434,6 +1435,7 @@
case CHOMPING_KEEP:
return b_asLineFeed();
}
+ throw "unreachable";
}
// 166
diff --git a/pkgs/yaml/lib/src/yaml_map.dart b/pkgs/yaml/lib/src/yaml_map.dart
index ab07c72..5e3e20a 100644
--- a/pkgs/yaml/lib/src/yaml_map.dart
+++ b/pkgs/yaml/lib/src/yaml_map.dart
@@ -55,7 +55,7 @@
/// Wraps an object for use as a key in the map.
_wrapKey(obj) {
if (obj != null && obj is! bool && obj is! List &&
- (obj is! double || !obj.isNan) &&
+ (obj is! num || !obj.isNaN) &&
(obj is! Map || obj is YamlMap)) {
return obj;
} else if (obj is Map) {