-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Description
I might be using more type-parameters than is useful :)
But I ran into this curious case, and wonder if it's a known regression.
typedef WrapperFn = Future<T> Function<T>(Future<T> Function() fn);
void acceptsWrapper(WrapperFn wrap) async {
// This works on Dart 2.7.0, but not Dart 2.8.1
ArgumentError.checkNotNull(wrap);
// This works fine on both Dart 2.7.0 and 2.8.1
if (wrap == null) {
throw ArgumentError.notNull();
}
await wrap(() async {
// Do something async that we want [wrap] to be able to initiate and
// return the result from, including catching exceptions.
});
}
void main() => print('hello world');
On dart 2.7.0
it works, but on 2.8.1
I get (before it starts running):
hack.dart:5:17: Error: Generic function type 'Future<T> Function<T>(Future<T> Function())' inferred as a type argument.
- 'Future' is from 'dart:async'.
Try providing a non-generic function type explicitly.
ArgumentError.checkNotNull(wrap);
)
Metadata
Metadata
Assignees
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).