Create a more stable ID for ConstantInfo
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a2d5cdb..1090b68 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.3+1
+
+- Improved the stability of `ConstantInfo.id`.
+
## 0.5.3
- Made IDs in the JSON format stable. Improves plain text diffing.
diff --git a/lib/info.dart b/lib/info.dart
index a5b83f0..afe7384 100644
--- a/lib/info.dart
+++ b/lib/info.dart
@@ -53,7 +53,7 @@
// TODO(sigmund): add more:
// - inputSize: bytes used in the Dart source program
abstract class BasicInfo implements Info {
- static Set<int> _ids = new Set<int>();
+ static final Set<int> _ids = new Set<int>();
final InfoKind kind;
int _id;
@@ -65,7 +65,16 @@
this is OutputUnitInfo ||
this.parent != null);
- _id = longName(this, useLibraryUri: true).hashCode;
+ if (this is ConstantInfo) {
+ // No name and no parent, so `longName` isn't helpful
+ assert(this.name == null);
+ assert(this.parent == null);
+ assert((this as ConstantInfo).code != null);
+ // Instead, use the content of the code.
+ _id = (this as ConstantInfo).code.hashCode;
+ } else {
+ _id = longName(this, useLibraryUri: true).hashCode;
+ }
while (!_ids.add(_id)) {
_id++;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 6d0d31b..efe0d4d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: dart2js_info
-version: 0.5.3
+version: 0.5.3+1
description: >
Libraries and tools to process data produced when running dart2js with
--dump-info.