From 0e64163408f24124adeed31a3031fdc7c183029d Mon Sep 17 00:00:00 2001
From: Kevin Moore <kevmoo@users.noreply.github.com>
Date: Wed, 1 May 2019 13:13:00 -0700
Subject: [PATCH] Enable and fix prefer_generic_function_type_aliases lint
 (#1020)

---
 analysis_options.yaml                         |  1 +
 pkgs/test_api/lib/src/frontend/expect.dart    |  4 +--
 .../lib/src/frontend/expect_async.dart        | 30 +++++++++----------
 .../lib/src/frontend/stream_matcher.dart      |  2 +-
 .../src/runner/configuration/reporters.dart   |  3 +-
 5 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/analysis_options.yaml b/analysis_options.yaml
index e1653118..bcfbd3fb 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -16,6 +16,7 @@ linter:
   rules:
     - await_only_futures
     - implementation_imports
+    - prefer_generic_function_type_aliases
     - prefer_typing_uninitialized_variables
     - unnecessary_const
     - unnecessary_new
diff --git a/pkgs/test_api/lib/src/frontend/expect.dart b/pkgs/test_api/lib/src/frontend/expect.dart
index 985c6054..7b5095ae 100644
--- a/pkgs/test_api/lib/src/frontend/expect.dart
+++ b/pkgs/test_api/lib/src/frontend/expect.dart
@@ -24,8 +24,8 @@ class TestFailure {
 /// The type used for functions that can be used to build up error reports
 /// upon failures in [expect].
 @Deprecated("Will be removed in 0.13.0.")
-typedef String ErrorFormatter(
-    actual, Matcher matcher, String reason, Map matchState, bool verbose);
+typedef ErrorFormatter = String Function(dynamic actual, Matcher matcher,
+    String reason, Map matchState, bool verbose);
 
 /// Assert that [actual] matches [matcher].
 ///
diff --git a/pkgs/test_api/lib/src/frontend/expect_async.dart b/pkgs/test_api/lib/src/frontend/expect_async.dart
index 883ade2c..3783ecb1 100644
--- a/pkgs/test_api/lib/src/frontend/expect_async.dart
+++ b/pkgs/test_api/lib/src/frontend/expect_async.dart
@@ -10,27 +10,27 @@ import 'expect.dart';
 
 // Function types returned by expectAsync# methods.
 
-typedef T Func0<T>();
-typedef T Func1<T, A>([A a]);
-typedef T Func2<T, A, B>([A a, B b]);
-typedef T Func3<T, A, B, C>([A a, B b, C c]);
-typedef T Func4<T, A, B, C, D>([A a, B b, C c, D d]);
-typedef T Func5<T, A, B, C, D, E>([A a, B b, C c, D d, E e]);
-typedef T Func6<T, A, B, C, D, E, F>([A a, B b, C c, D d, E e, F f]);
+typedef Func0<T> = T Function();
+typedef Func1<T, A> = T Function([A a]);
+typedef Func2<T, A, B> = T Function([A a, B b]);
+typedef Func3<T, A, B, C> = T Function([A a, B b, C c]);
+typedef Func4<T, A, B, C, D> = T Function([A a, B b, C c, D d]);
+typedef Func5<T, A, B, C, D, E> = T Function([A a, B b, C c, D d, E e]);
+typedef Func6<T, A, B, C, D, E, F> = T Function([A a, B b, C c, D d, E e, F f]);
 
 // Functions used to check how many arguments a callback takes. We can't use the
 // previous functions for this, because (a) {} is not a subtype of
 // ([dynamic]) -> dynamic.
 
-typedef _Func0();
-typedef _Func1(Null a);
-typedef _Func2(Null a, Null b);
-typedef _Func3(Null a, Null b, Null c);
-typedef _Func4(Null a, Null b, Null c, Null d);
-typedef _Func5(Null a, Null b, Null c, Null d, Null e);
-typedef _Func6(Null a, Null b, Null c, Null d, Null e, Null f);
+typedef _Func0 = Function();
+typedef _Func1 = Function(Null a);
+typedef _Func2 = Function(Null a, Null b);
+typedef _Func3 = Function(Null a, Null b, Null c);
+typedef _Func4 = Function(Null a, Null b, Null c, Null d);
+typedef _Func5 = Function(Null a, Null b, Null c, Null d, Null e);
+typedef _Func6 = Function(Null a, Null b, Null c, Null d, Null e, Null f);
 
-typedef bool _IsDoneCallback();
+typedef _IsDoneCallback = bool Function();
 
 /// A wrapper for a function that ensures that it's called the appropriate
 /// number of times.
diff --git a/pkgs/test_api/lib/src/frontend/stream_matcher.dart b/pkgs/test_api/lib/src/frontend/stream_matcher.dart
index ecf72e08..e37c5c6a 100644
--- a/pkgs/test_api/lib/src/frontend/stream_matcher.dart
+++ b/pkgs/test_api/lib/src/frontend/stream_matcher.dart
@@ -13,7 +13,7 @@ import 'async_matcher.dart';
 import 'format_stack_trace.dart';
 
 /// The type for [_StreamMatcher._matchQueue].
-typedef Future<String> _MatchQueue(StreamQueue queue);
+typedef _MatchQueue = Future<String> Function(StreamQueue queue);
 
 /// A matcher that matches events from [Stream]s or [StreamQueue]s.
 ///
diff --git a/pkgs/test_core/lib/src/runner/configuration/reporters.dart b/pkgs/test_core/lib/src/runner/configuration/reporters.dart
index e0c7501e..1bf56630 100644
--- a/pkgs/test_core/lib/src/runner/configuration/reporters.dart
+++ b/pkgs/test_core/lib/src/runner/configuration/reporters.dart
@@ -15,7 +15,8 @@ import '../reporter/json.dart';
 
 /// Constructs a reporter for the provided engine with the provided
 /// configuration.
-typedef Reporter ReporterFactory(Configuration configuration, Engine engine);
+typedef ReporterFactory = Reporter Function(
+    Configuration configuration, Engine engine);
 
 /// Container for a reporter description and corresponding factory.
 class ReporterDetails {
-- 
GitLab