• Bob Nystrom's avatar
    Fix covariant overrides in SynchronousFuture. (#5262) · b504fd42
    Bob Nystrom authored
    * Fix covariant overrides in SynchronousFuture.
    
    There were two things going on here. In timeout(), the callback's return
    type was needlessly tightened to only allow callbacks that return
    futures. This makes SynchronousFuture not substitutable with Future,
    whose timeout() allows callbacks that return immediate values.
    
    Since SynchronousFuture.timeout() never calls the callback anyway, I
    just loosened it to match Future.timeout().
    
    SynchronousFuture.whenComplete() is just wrong. The type error, again,
    is that the callback's return type is too tight. Future.whenComplete()
    allows synchronous callbacks.
    
    But the actual implementation is wrong as well. whenComplete() should
    return a future that completes to the *original value*, not whatever the
    callback returns.
    
    So I just fixed the method to work correctly, including handling
    callbacks with synchronous results.
    
    * "(error, stackTrace)" -> "(e, stack)".
    b504fd42
Name
Last commit
Last update
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.analysis_options Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
ISSUE_TEMPLATE.md Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
VERSION Loading commit data...