mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:59:41 +00:00
Observatory strong mode fix: fix type errors with onDisconnect.
The method ObservatoryApplication._switchVM calls newVM.onDisconnect and requires the resulting future to be completed with a String. In normal operation, this is satisfied and we just need to change a few static types to enforce it. But when FakeVM was in use, the future was completed with `this`. Since ObservatoryApplication._switchVM is the only call site that cares what the future is completed with, it makes sense to just change all the types to Future<String> and modify FakeVM accordingly. Change-Id: Id94d27ac6a42f31ab19ccc9ad8dd270ecf4042b4 Reviewed-on: https://dart-review.googlesource.com/57400 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
3027302af6
commit
9e3842d624
|
@ -77,7 +77,7 @@ abstract class CommonWebSocket {
|
|||
/// The Dart VM can be embedded in Chromium or standalone.
|
||||
abstract class CommonWebSocketVM extends VM {
|
||||
final Completer _connected = new Completer();
|
||||
final Completer _disconnected = new Completer<String>();
|
||||
final Completer<String> _disconnected = new Completer<String>();
|
||||
final WebSocketVMTarget target;
|
||||
final Map<String, _WebSocketRequest> _delayedRequests =
|
||||
new Map<String, _WebSocketRequest>();
|
||||
|
@ -114,7 +114,7 @@ abstract class CommonWebSocketVM extends VM {
|
|||
}
|
||||
}
|
||||
|
||||
Future get onDisconnect => _disconnected.future;
|
||||
Future<String> get onDisconnect => _disconnected.future;
|
||||
bool get isDisconnected => _disconnected.isCompleted;
|
||||
|
||||
void disconnect({String reason: 'WebSocket closed'}) {
|
||||
|
|
|
@ -963,7 +963,7 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
|
|||
Future get onConnect;
|
||||
|
||||
/// Completes when the VM disconnects or there was an error connecting.
|
||||
Future get onDisconnect;
|
||||
Future<String> get onDisconnect;
|
||||
|
||||
void _update(Map map, bool mapIsRef) {
|
||||
name = map['name'];
|
||||
|
@ -1047,7 +1047,7 @@ class FakeVM extends VM {
|
|||
|
||||
/// Force the VM to disconnect.
|
||||
void disconnect() {
|
||||
_onDisconnect.complete(this);
|
||||
_onDisconnect.complete('Disconnected');
|
||||
}
|
||||
|
||||
// Always connected.
|
||||
|
@ -1062,8 +1062,8 @@ class FakeVM extends VM {
|
|||
|
||||
bool get isConnected => !isDisconnected;
|
||||
// Only complete when requested.
|
||||
Completer _onDisconnect = new Completer();
|
||||
Future get onDisconnect => _onDisconnect.future;
|
||||
Completer<String> _onDisconnect = new Completer<String>();
|
||||
Future<String> get onDisconnect => _onDisconnect.future;
|
||||
bool get isDisconnected => _onDisconnect.isCompleted;
|
||||
|
||||
Future<Map> invokeRpcRaw(String method, Map params) {
|
||||
|
|
Loading…
Reference in a new issue