Fix detecting argument count of async function (#1482)

diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md
index 6485f1e..b988a2d 100644
--- a/pkgs/test/CHANGELOG.md
+++ b/pkgs/test/CHANGELOG.md
@@ -7,6 +7,7 @@
 * Disable stack trace chaining by default. It can be re-enabled by explicitly
   passing the `--chain-stack-traces` flag.
 * Remove `phantomjs` support completely, it was previously broken.
+* Fix `expectAsync` function type checks.
 
 ## 1.16.8
 
diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml
index d5ddd92..2c5a44a 100644
--- a/pkgs/test/pubspec.yaml
+++ b/pkgs/test/pubspec.yaml
@@ -33,7 +33,7 @@
   webkit_inspection_protocol: ^1.0.0
   yaml: ^3.0.0
   # Use an exact version until the test_api and test_core package are stable.
-  test_api: 0.3.1
+  test_api: 0.4.0
   test_core: 0.3.20
 
 dev_dependencies:
diff --git a/pkgs/test_api/CHANGELOG.md b/pkgs/test_api/CHANGELOG.md
index 1eeb169..bc661ec 100644
--- a/pkgs/test_api/CHANGELOG.md
+++ b/pkgs/test_api/CHANGELOG.md
@@ -2,6 +2,7 @@
 
 * Add examples to `throwsA` and make top-level `throws...` matchers refer to it.
 * Disable stack trace chaining by default.
+* Fix `expectAsync` function type checks.
 * **Breaking** remove `Runtime.phantomJS`
 * **Breaking** Add callback to get the suite channel in the `beforeLoad`
   callback of `RemoteListener.start`. This is now used in place of using zones
diff --git a/pkgs/test_api/lib/src/frontend/expect_async.dart b/pkgs/test_api/lib/src/frontend/expect_async.dart
index 17f0e54..95ab80a 100644
--- a/pkgs/test_api/lib/src/frontend/expect_async.dart
+++ b/pkgs/test_api/lib/src/frontend/expect_async.dart
@@ -124,12 +124,14 @@
   /// Returns a function that has the same number of positional arguments as the
   /// wrapped function (up to a total of 6).
   Function get func {
-    if (_callback is Function(Null, Null, Null, Null, Null Nulll)) return max6;
-    if (_callback is Function(Null, Null, Null, Null, Null)) return max5;
-    if (_callback is Function(Null, Null, Null, Null)) return max4;
-    if (_callback is Function(Null, Null, Null)) return max3;
-    if (_callback is Function(Null, Null)) return max2;
-    if (_callback is Function(Null)) return max1;
+    if (_callback is Function(Never, Never, Never, Never, Never, Never)) {
+      return max6;
+    }
+    if (_callback is Function(Never, Never, Never, Never, Never)) return max5;
+    if (_callback is Function(Never, Never, Never, Never)) return max4;
+    if (_callback is Function(Never, Never, Never)) return max3;
+    if (_callback is Function(Never, Never)) return max2;
+    if (_callback is Function(Never)) return max1;
     if (_callback is Function()) return max0;
 
     _invoker!.removeOutstandingCallback();
diff --git a/pkgs/test_api/test/frontend/expect_async_test.dart b/pkgs/test_api/test/frontend/expect_async_test.dart
index 2bf2766..539ce2d 100644
--- a/pkgs/test_api/test/frontend/expect_async_test.dart
+++ b/pkgs/test_api/test/frontend/expect_async_test.dart
@@ -25,7 +25,7 @@
     test('1', () async {
       var callbackRun = false;
       var liveTest = await runTestBody(() {
-        expectAsync1((arg) {
+        expectAsync1((int arg) {
           expect(arg, equals(1));
           callbackRun = true;
         })(1);
@@ -319,7 +319,7 @@
       expect(callbackRun, isTrue);
     });
 
-    test('works with arguments', () async {
+    test('works with dynamic arguments', () async {
       var callbackRun = false;
       var liveTest = await runTestBody(() {
         expectAsync((arg1, arg2) {
@@ -331,6 +331,30 @@
       expect(callbackRun, isTrue);
     });
 
+    test('works with non-nullable arguments', () async {
+      var callbackRun = false;
+      var liveTest = await runTestBody(() {
+        expectAsync((int arg1, int arg2) {
+          callbackRun = true;
+        })(1, 2);
+      });
+
+      expectTestPassed(liveTest);
+      expect(callbackRun, isTrue);
+    });
+
+    test('works with 6 arguments', () async {
+      var callbackRun = false;
+      var liveTest = await runTestBody(() {
+        expectAsync((arg1, arg2, arg3, arg4, arg5, arg6) {
+          callbackRun = true;
+        })(1, 2, 3, 4, 5, 6);
+      });
+
+      expectTestPassed(liveTest);
+      expect(callbackRun, isTrue);
+    });
+
     test("doesn't support a function with 7 arguments", () {
       expect(() => expectAsync((_1, _2, _3, _4, _5, _6, _7) {}),
           throwsArgumentError);
diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml
index afea13c..9380aa1 100644
--- a/pkgs/test_core/pubspec.yaml
+++ b/pkgs/test_core/pubspec.yaml
@@ -31,7 +31,7 @@
   # matcher is tightly constrained by test_api
   matcher: any
   # Use an exact version until the test_api package is stable.
-  test_api: 0.3.1
+  test_api: 0.4.0
 
 dependency_overrides:
   test_api: