  
      return _stdoutHandler.compilerOutput.future;
    }
-@@ -597,6 +629,7 @@ class ResidentCompiler {
+@@ -570,7 +608,7 @@ class ResidentCompiler {
+   }
+ 
+   Future<CompilerOutput> _compileExpression(_CompileExpressionRequest request) async {
+-    _stdoutHandler.reset(suppressCompilerMessages: true);
++    _stdoutHandler.reset(suppressCompilerMessages: true, expectSources: false);
+ 
+     // 'compile-expression' should be invoked after compiler has been started,
+     // program was compiled.
+@@ -597,6 +635,7 @@ class ResidentCompiler {
    void accept() {
      if (_compileRequestNeedsConfirmation) {
        _server.stdin.writeln('accept');

-      if (compilerMessageReceived == false) {
-        consumer('\nCompiler message:');
-        compilerMessageReceived = true;
+    } else {
+      if (state == StdoutState.CollectDiagnostic) {
+        if (!_suppressCompilerMessages) {
+          if (compilerMessageReceived == false) {
+            consumer('\nCompiler message:');
+            compilerMessageReceived = true;
+          }
+          consumer(message);
+        }
+      } else {
+        assert(state == StdoutState.CollectDependencies);
+        switch (message[0]) {
+          case '+':
+            sources.add(Uri.parse(message.substring(1)));
+            break;
+          case '-':
+            sources.remove(Uri.parse(message.substring(1)));
+            break;
+          default:
+            printTrace('Unexpected prefix for $message uri - ignoring');
+        }
       }
-      consumer(message);
     }
   }
 
@@ -106,6 +133,7 @@ class StdoutHandler {
     compilerMessageReceived = false;
     compilerOutput = Completer<CompilerOutput>();
     _suppressCompilerMessages = suppressCompilerMessages;
+    state = StdoutState.CollectDiagnostic;
   }
 }
 
@@ -200,7 +228,7 @@ class KernelCompiler {
 
       if (await fingerprinter.doesFingerprintMatch()) {
         printTrace('Skipping kernel compilation. Fingerprint match.');

     _compileRequestNeedsConfirmation = false;
     return _stdoutHandler.compilerOutput.future;
   }
@@ -629,6 +669,7 @@ class ResidentCompiler {
   /// kernel file.
   void reset() {
     _server?.stdin?.writeln('reset');
