Index: pkg/compiler/lib/src/elements/elements.dart |
diff --git a/pkg/compiler/lib/src/elements/elements.dart b/pkg/compiler/lib/src/elements/elements.dart |
index ba4bdf0df8c06018f5de1acfb63ea0647a2454b4..fe12019de8e4c6c5fe0e68d0c6f1d209d76e7325 100644 |
--- a/pkg/compiler/lib/src/elements/elements.dart |
+++ b/pkg/compiler/lib/src/elements/elements.dart |
@@ -644,6 +644,15 @@ class Elements { |
return null; |
} |
+ /// If `true`, injected members are sorted with their corresponding class or |
+ /// library. |
+ /// |
+ /// This is used for ensuring equivalent output order when testing against |
+ /// .dill using the patched_dart2js_sdk. |
+ // TODO(johnniwinther): Remove this when patching is implemented in |
+ // package:front_end. |
+ static bool usePatchedDart2jsSdkSorting = false; |
+ |
/// A `compareTo` function that places [Element]s in a consistent order based |
/// on the source code order. |
static int compareByPosition(Element a, Element b) { |
@@ -651,8 +660,22 @@ class Elements { |
int r = utils.compareLibrariesUris( |
a.library.canonicalUri, b.library.canonicalUri); |
if (r != 0) return r; |
- r = utils.compareSourceUris(a.compilationUnit.script.readableUri, |
- b.compilationUnit.script.readableUri); |
+ Uri aUri = a.compilationUnit.script.readableUri; |
+ Uri bUri = b.compilationUnit.script.readableUri; |
+ if (usePatchedDart2jsSdkSorting) { |
+ Uri computePatchedDart2jsUri(Element e, Uri uri) { |
+ if (!e.isInjected) return uri; |
+ if (e.enclosingClass != null) { |
+ return e.enclosingClass.compilationUnit.script.readableUri; |
+ } else { |
+ return e.library.compilationUnit.script.readableUri; |
+ } |
+ } |
+ |
+ aUri = computePatchedDart2jsUri(a, aUri); |
+ bUri = computePatchedDart2jsUri(b, bUri); |
+ } |
+ r = utils.compareSourceUris(aUri, bUri); |
if (r != 0) return r; |
return utils.compareEntities(a, a.sourceOffset, -1, b, b.sourceOffset, -1); |
} |