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

Unified Diff: pkg/compiler/lib/src/elements/elements.dart

Issue 2958553002: Sort type tests. (Closed)
Patch Set: Updated cf. comment Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698