Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider hard-coding generic type info for dart.async::Future.then #13

Open
jvasileff opened this issue Jul 15, 2016 · 1 comment
Open

Comments

@jvasileff
Copy link
Owner

jvasileff commented Jul 15, 2016

Future.then (docs) is defined as:

Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), { Function onError });

which results in the return type Future<Nothing> in Ceylon. Instead, we should consider hard-coding the model to have something like:

Future<S> then<S>(S|Future<S> onValue(T value), ...);

although, it may need to be more complicated, like:

Future<S|E|Throwable> then<S,E=Nothing>(S|Future<S> onValue(T value), E onError(Nothing) = nothing)

which starts to defeat the purpose. Especially since non-Throwables can be thrown in Dart. So, would we actually wind up with a return type of Future<Anything>?

Edit: not sure why I had Throwable in the union. Need to test this. It might be:

Future<S|E> then<S,E=Nothing>(S|Future<S> onValue(T value), E onError(Nothing) = nothing)
@jvasileff
Copy link
Owner Author

An argument not to do this is in increases the likelihood of mistakenly winding up with a nested Future<Future<T>> result, which will actually be Future<T> since Dart unwraps Futures returned by onValue.

And, type inference seems to prefer the nested option for S|Future<S> (i.e. it ignores the Future<S> part of the union, so the inferred type is not unwrapped).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant