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

Unified Diff: lib/src/codegen/js_module_item_order.dart

Issue 1170813008: fixes detection of SDK libraries (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 5 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
Index: lib/src/codegen/js_module_item_order.dart
diff --git a/lib/src/codegen/js_module_item_order.dart b/lib/src/codegen/js_module_item_order.dart
index 072e170d1d76f7f102b33be933af148fa0abdbe4..48626a574e4cb45a19476b59da3a51a1c7018ee2 100644
--- a/lib/src/codegen/js_module_item_order.dart
+++ b/lib/src/codegen/js_module_item_order.dart
@@ -182,9 +182,9 @@ class ModuleItemLoadOrder {
assert(library != _currentLibrary);
// The SDK is a special case: we optimize the order to prevent laziness.
- if (library.isInSdk) {
+ if (_isDartUri(library)) {
// SDK is loaded before non-SDK libraries
- if (!_currentLibrary.isInSdk) return true;
+ if (!_isDartUri(_currentLibrary)) return true;
// Compute the order of both SDK libraries. If unknown, assume it's after.
var order = corelibOrder.indexOf(library.name);
@@ -209,7 +209,7 @@ class ModuleItemLoadOrder {
bool _inLibraryCycle(LibraryElement library) {
// SDK libs don't depend on things outside the SDK.
// (We can reach this via the recursive call below.)
- if (library.isInSdk && !_currentLibrary.isInSdk) return false;
+ if (_isDartUri(library) && !_isDartUri(_currentLibrary)) return false;
var result = _libraryCycleMemo[library];
if (result != null) return result;
@@ -226,4 +226,10 @@ class ModuleItemLoadOrder {
}
return _libraryCycleMemo[library] = result;
}
+
+ /// Returns whether this is a library imported with 'dart:' URI.
+ ///
+ /// This is similar to [LibraryElement.isInSdk], but checking the URI instead
+ /// of the library naming convention, because the URI is reliable.
+ static bool _isDartUri(LibraryElement e) => e.source.uri.scheme == 'dart';
vsm 2015/06/10 16:41:15 Do you want to assert e.isInSdk == _isDartUri(e)?
Jennifer Messerly 2015/06/10 16:46:04 We can't assert it, because user can name their li
}
« lib/devc.dart ('K') | « lib/src/codegen/js_codegen.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698