Return full stack chains for unregistered traces

Previously we were just returning these traces as-is, even when we
had a _currentNode chain context available.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19fb82b..e8e717e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.8.3
+
+* `Chain.forTrace()` now returns a full stack chain for *all* `StackTrace`s
+  within `Chain.capture()`, even those that haven't been processed by
+  `dart:async` yet.
+
 ## 1.8.2
 
 * Update to use strong-mode clean Zone API.
diff --git a/lib/src/stack_zone_specification.dart b/lib/src/stack_zone_specification.dart
index 6749d56..7205a4e 100644
--- a/lib/src/stack_zone_specification.dart
+++ b/lib/src/stack_zone_specification.dart
@@ -86,7 +86,7 @@
   /// with [trace], this just returns a single-trace chain containing [trace].
   Chain chainFor(StackTrace trace) {
     if (trace is Chain) return trace;
-    var previous = trace == null ? null : _chains[trace];
+    var previous = (trace == null ? null : _chains[trace]) ?? _currentNode;
     return new _Node(trace, previous).toChain();
   }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index a6e5b92..79cf0b0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -7,7 +7,7 @@
 #
 # When the major version is upgraded, you *must* update that version constraint
 # in pub to stay in sync with this.
-version: 1.8.2
+version: 1.8.3-dev
 author: "Dart Team <misc@dartlang.org>"
 homepage: https://github.com/dart-lang/stack_trace
 description: A package for manipulating stack traces and printing them readably.
diff --git a/test/chain/vm_test.dart b/test/chain/vm_test.dart
index daf7f8f..3378bc2 100644
--- a/test/chain/vm_test.dart
+++ b/test/chain/vm_test.dart
@@ -8,9 +8,11 @@
 
 import 'dart:async';
 
-import 'package:stack_trace/stack_trace.dart';
 import 'package:test/test.dart';
 
+import 'package:stack_trace/stack_trace.dart';
+import 'package:stack_trace/src/utils.dart';
+
 import '../utils.dart';
 import 'utils.dart';
 
@@ -444,11 +446,10 @@
       });
     });
 
-    test(
-        'called for an unregistered stack trace returns a chain wrapping that '
-        'trace', () {
+    test('called for an unregistered stack trace uses the current chain',
+        () async {
       var trace;
-      var chain = Chain.capture(() {
+      var chain = await Chain.capture(() async {
         try {
           throw 'error';
         } catch (_, stackTrace) {
@@ -457,27 +458,33 @@
         }
       });
 
-      expect(chain.traces, hasLength(1));
+      expect(chain.traces, hasLength(2));
       expect(chain.traces.first.toString(),
           equals(new Trace.from(trace).toString()));
+      expect(
+          chain.traces.last.frames, contains(frameMember(startsWith('main'))));
     });
   });
 
   test(
-      'forTrace() outside of capture() returns a chain wrapping the given '
-      'trace', () {
-    var trace;
-    var chain = Chain.capture(() {
-      try {
-        throw 'error';
-      } catch (_, stackTrace) {
-        trace = stackTrace;
-        return new Chain.forTrace(stackTrace);
-      }
-    });
+      'forTrace() outside of capture() returns a chain describing the VM stack '
+      'chain', () {
+    // Disable the test package's chain-tracking.
+    return Chain.disable(() async {
+      var trace;
+      await Chain.capture(() async {
+        try {
+          throw 'error';
+        } catch (_, stackTrace) {
+          trace = stackTrace;
+        }
+      });
 
-    expect(chain.traces, hasLength(1));
-    expect(chain.traces.first.toString(),
-        equals(new Trace.from(trace).toString()));
+      var chain = new Chain.forTrace(trace);
+      expect(chain.traces,
+          hasLength(vmChainGap.allMatches(trace.toString()).length + 1));
+      expect(
+          chain.traces.first.frames, contains(frameMember(startsWith('main'))));
+    });
   });
 }