Add tests showing the async impact on function type checks

Change-Id: I8a59560dc18a8d491150d2c72287c2025e13beda
Reviewed-on: https://dart-review.googlesource.com/62061
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart b/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart
index 37dac4c..15dd004 100644
--- a/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart
+++ b/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart
@@ -452,6 +452,31 @@
     }
     return _computedDataForEachFile[file];
   }
+
+  String toString() {
+    StringBuffer sb = new StringBuffer();
+    sb.write('MemberAnnotations(');
+    String comma = '';
+    if (_computedDataForEachFile.isNotEmpty &&
+        (_computedDataForEachFile.length > 1 ||
+            _computedDataForEachFile.values.single.isNotEmpty)) {
+      sb.write('data:{');
+      _computedDataForEachFile.forEach((Uri uri, Map<Id, DataType> data) {
+        sb.write(comma);
+        sb.write('$uri:');
+        sb.write(data);
+        comma = ',';
+      });
+      sb.write('}');
+    }
+    if (globalData.isNotEmpty) {
+      sb.write(comma);
+      sb.write('global:');
+      sb.write(globalData);
+    }
+    sb.write(')');
+    return sb.toString();
+  }
 }
 
 typedef void Callback();
diff --git a/tests/compiler/dart2js/rti/data/async_foreach.dart b/tests/compiler/dart2js/rti/data/async_foreach.dart
new file mode 100644
index 0000000..775cdbe
--- /dev/null
+++ b/tests/compiler/dart2js/rti/data/async_foreach.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/*kernel.class: Class:*/
+/*strong.class: Class:direct,explicit=[Class.T],implicit=[Class.T],needsArgs*/
+/*omit.class: Class:needsArgs*/
+class Class<T> {
+  method() {
+    var list = <T>[];
+    // With the `is dynamic Function(Object)` test in the async implementation
+    // the closure, with type `dynamic Function(T)`, needs its signature,
+    // requiring the need for type arguments on `Class`.
+    //
+    // This happens because the closure is thought as possibly going to the
+    // async.errorHandler callback.
+    list.forEach(
+        /*strong.needsSignature*/
+        /*omit.needsSignature*/
+        (x) => print(x));
+  }
+}
+
+main() async {
+  new Class<int>().method();
+}
diff --git a/tests/compiler/dart2js/rti/data/async_foreach_nonasync.dart b/tests/compiler/dart2js/rti/data/async_foreach_nonasync.dart
new file mode 100644
index 0000000..2e390bf
--- /dev/null
+++ b/tests/compiler/dart2js/rti/data/async_foreach_nonasync.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/*kernel.class: Class:*/
+/*strong.class: Class:direct,explicit=[Class.T],implicit=[Class.T],needsArgs*/
+/*omit.class: Class:*/
+class Class<T> {
+  method() {
+    var list = <T>[];
+    // If any method was `async`, this would have triggered the need for type
+    // arguments on `Class`. See the 'async_foreach.dart' test.
+    list.forEach(
+        /*strong.needsSignature*/
+        /*omit.*/
+        (x) => print(x));
+  }
+}
+
+main() {
+  new Class<int>().method();
+}
diff --git a/tests/compiler/dart2js/rti/data/async_local.dart b/tests/compiler/dart2js/rti/data/async_local.dart
new file mode 100644
index 0000000..45f0a91
--- /dev/null
+++ b/tests/compiler/dart2js/rti/data/async_local.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+main() async {
+  // With the `is dynamic Function(Object,StackTrace)` test in the async
+  // implementation the closure, with type `dynamic Function(dynamic, dynamic)`,
+  // needs its signature.
+  //
+  // This happens because the closure is thought as possibly going to the
+  // async.errorHandler callback.
+  /*kernel.*/
+  /*strong.needsSignature*/
+  /*omit.needsSignature*/
+  local(object, stacktrace) => null;
+
+  return local;
+}
diff --git a/tests/compiler/dart2js/rti/data/async_local_nonasync.dart b/tests/compiler/dart2js/rti/data/async_local_nonasync.dart
new file mode 100644
index 0000000..4651639
--- /dev/null
+++ b/tests/compiler/dart2js/rti/data/async_local_nonasync.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+main() {
+  // If any method was `async`, this would have triggered the need for the
+  // signature on this closure. See the 'async_local.dart' test.
+  /*kernel.*/
+  /*strong.*/
+  /*omit.*/
+  local(object, stacktrace) => null;
+
+  return local;
+}
diff --git a/tests/compiler/dart2js/rti/data/async_local_typed.dart b/tests/compiler/dart2js/rti/data/async_local_typed.dart
new file mode 100644
index 0000000..40de910
--- /dev/null
+++ b/tests/compiler/dart2js/rti/data/async_local_typed.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/*kernel.class: Class:*/
+/*strong.class: Class:explicit=[Class<int>],needsArgs*/
+/*omit.class: Class:*/
+class Class<T> {}
+
+main() async {
+  // Despite the `is dynamic Function(Object,StackTrace)` test in the async
+  // implementation the closure, with type
+  // `dynamic Function(dynamic, Class<int>)`, is not a potential subtype and
+  // therefore doesn't need its signature.
+  /*kernel.*/
+  /*strong.needsSignature*/
+  /*omit.*/
+  local(object, Class<int> stacktrace) => null;
+
+  return local;
+}