Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit de508ca

Browse files
authored
Remove 'implements Function' from MethodProxy (#45)
The ability to implement the `Function` interface has been deprecated in the SDK. This change also adds dartdoc explaining the implications of our use of `noSuchMethod` in the record_replay library.
1 parent d6795a9 commit de508ca

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

lib/src/backends/record_replay/proxy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ abstract class ProxyObject {}
1212
/// This is used when a caller accesses a method on a [ProxyObject] via the
1313
/// method's getter. In these cases, the caller will receive a [MethodProxy]
1414
/// that allows delayed invocation of the method.
15-
class MethodProxy extends Object implements Function {
15+
class MethodProxy {
1616
/// The object on which the method was retrieved.
1717
///
1818
/// This will be the target object when this method proxy is invoked.

lib/src/backends/record_replay/recording_file_system.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ import 'replay_file_system.dart';
3636
/// assertions in your tests about which methods were invoked and in what
3737
/// order.
3838
///
39+
/// *Implementation note*: this class uses [noSuchMethod] to dynamically handle
40+
/// invocations. As a result, method references on objects herein will not pass
41+
/// `is` checks or checked-mode checks on type. For example:
42+
///
43+
/// ```dart
44+
/// typedef FileStat StatSync(String path);
45+
/// FileSystem fs = new RecordingFileSystem(delegate: delegate, destination: dir);
46+
///
47+
/// StatSync method = fs.statSync; // Will fail in checked-mode
48+
/// fs.statSync is StatSync // Will return false
49+
/// fs.statSync is Function // Will return false
50+
///
51+
/// dynamic method2 = fs.statSync; // OK
52+
/// FileStat stat = method2('/path'); // OK
53+
/// ```
54+
///
3955
/// See also:
4056
/// - [ReplayFileSystem]
4157
abstract class RecordingFileSystem extends FileSystem {

lib/src/backends/record_replay/replay_file_system.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ import 'replay_proxy_mixin.dart';
4141
/// assertions in your tests about which methods were invoked and in what
4242
/// order.
4343
///
44+
/// *Implementation note*: this class uses [noSuchMethod] to dynamically handle
45+
/// invocations. As a result, method references on objects herein will not pass
46+
/// `is` checks or checked-mode checks on type. For example:
47+
///
48+
/// ```dart
49+
/// typedef FileStat StatSync(String path);
50+
/// FileSystem fs = new ReplayFileSystem(directory);
51+
///
52+
/// StatSync method = fs.statSync; // Will fail in checked-mode
53+
/// fs.statSync is StatSync // Will return false
54+
/// fs.statSync is Function // Will return false
55+
///
56+
/// dynamic method2 = fs.statSync; // OK
57+
/// FileStat stat = method2('/path'); // OK
58+
/// ```
59+
///
4460
/// See also:
4561
/// - [RecordingFileSystem]
4662
abstract class ReplayFileSystem extends FileSystem {

test/common_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ void runCommonTests(
22762276
});
22772277

22782278
test('blocksCallToFlushWhileStreamIsActive', () {
2279-
expect(sink.flush, throwsStateError);
2279+
expect(() => sink.flush(), throwsStateError);
22802280
});
22812281
});
22822282
});

0 commit comments

Comments
 (0)