Dill loader.builders shouldn't have `dart:` uris removed

Change-Id: I96b2d995058a014af8d23addd66a893b9b740fe6
Reviewed-on: https://dart-review.googlesource.com/c/88569
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index 2ba7eb7..e4fd12d 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -222,8 +222,6 @@
             " of ${userCode.loader.builders.length} libraries");
       }
 
-      reusedLibraries.addAll(platformBuilders);
-
       KernelTarget userCodeOld = userCode;
       userCode = new KernelTarget(
           new HybridFileSystem(
@@ -559,11 +557,11 @@
   List<LibraryBuilder> computeReusedLibraries(
       Set<Uri> invalidatedUris, UriTranslator uriTranslator,
       {Set<LibraryBuilder> notReused}) {
-    if (userCode == null && userBuilders == null) {
-      return <LibraryBuilder>[];
-    }
-
     List<LibraryBuilder> result = <LibraryBuilder>[];
+    result.addAll(platformBuilders);
+    if (userCode == null && userBuilders == null) {
+      return result;
+    }
 
     // Maps all non-platform LibraryBuilders from their import URI.
     Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{};
diff --git a/pkg/front_end/test/incremental_load_from_dill_test.dart b/pkg/front_end/test/incremental_load_from_dill_test.dart
index 8a1495d4..0e1d3a8 100644
--- a/pkg/front_end/test/incremental_load_from_dill_test.dart
+++ b/pkg/front_end/test/incremental_load_from_dill_test.dart
@@ -484,4 +484,20 @@
   void recordInvalidatedImportUrisForTesting(List<Uri> uris) {
     invalidatedImportUrisForTesting = uris.isEmpty ? null : uris.toSet();
   }
+
+  @override
+  Future<Component> computeDelta(
+      {Uri entryPoint, bool fullComponent = false}) async {
+    Component result = await super
+        .computeDelta(entryPoint: entryPoint, fullComponent: fullComponent);
+
+    // We should at least have the SDK builders available. Slight smoke test.
+    if (!dillLoadedData.loader.builders.keys
+        .map((uri) => uri.toString())
+        .contains("dart:core")) {
+      throw "Loaders builder should contain the sdk, "
+          "but didn't even contain dart:core.";
+    }
+    return result;
+  }
 }