You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import 'package:pool/pool.dart';
main() async {
Pool pool = new Pool(1);
String s = await pool.withResource(() async => "Hi");
print(s);
}
However in strong mode I get the following errors:
dartanalyzer --strong bin/testpool.dart
Analyzing [bin/testpool.dart]...
[error] Couldn't infer type parameter 'T'; 'Future' must be of type 'String'. (/home/adam/dev/fp3/dart/yacht/bin/testpool.dart, line 6, col 25)
[error] The argument type '() → Future' can't be assigned to the parameter type '() → String'. (/home/adam/dev/fp3/dart/yacht/bin/testpool.dart, line 6, col 38)
2 errors found.
I believe this is because withResource allows callback to return a T or Future<T> but this is not reflected in the function signature. Probably the type of callback should be: FutureOr<T> callback().
The text was updated successfully, but these errors were encountered:
The following code runs fine:
However in strong mode I get the following errors:
I believe this is because
withResource
allowscallback
to return aT
orFuture<T>
but this is not reflected in the function signature. Probably the type of callback should be:FutureOr<T> callback()
.The text was updated successfully, but these errors were encountered: