mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:07:06 +00:00
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>
This commit is contained in:
parent
8e4d5c0a38
commit
2c98fb3c1d
|
@ -452,6 +452,31 @@ class MemberAnnotations<DataType> {
|
|||
}
|
||||
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();
|
||||
|
|
26
tests/compiler/dart2js/rti/data/async_foreach.dart
Normal file
26
tests/compiler/dart2js/rti/data/async_foreach.dart
Normal file
|
@ -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();
|
||||
}
|
22
tests/compiler/dart2js/rti/data/async_foreach_nonasync.dart
Normal file
22
tests/compiler/dart2js/rti/data/async_foreach_nonasync.dart
Normal file
|
@ -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();
|
||||
}
|
18
tests/compiler/dart2js/rti/data/async_local.dart
Normal file
18
tests/compiler/dart2js/rti/data/async_local.dart
Normal file
|
@ -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;
|
||||
}
|
14
tests/compiler/dart2js/rti/data/async_local_nonasync.dart
Normal file
14
tests/compiler/dart2js/rti/data/async_local_nonasync.dart
Normal file
|
@ -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;
|
||||
}
|
21
tests/compiler/dart2js/rti/data/async_local_typed.dart
Normal file
21
tests/compiler/dart2js/rti/data/async_local_typed.dart
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue