Skip to content

Commit ed47cc0

Browse files
stereotype441tvolkert
authored andcommitted
Make ForwardingDirectory generic. (flutter#74)
Due to an upcoming change in Dart 2.0 (dart-lang/sdk#32148), it will no longer be allowed for a class to implement the same generic interface in different ways. (E.g. a class cannot implement/extend/mixin both A<int> and A<String>). This causes problems with _LocalDirectory. It extends _LocalFileSystemEntity<_LocalDirectory, Directory>, which extends ForwardingFileSystemEntity<_LocalDirectory, Directory>, but it mixes in ForwardingDirectory, which extends ForwardingFileSystemEntity<Directory, io.Directory>. The solution is to make ForwardingDirectory a generic mixin, with ForwardingDirectory<T> extending ForwardingFileSystemEntity<T, io.Directory>. Type inference automatically fills in the type argument T=_LocalDirectory at the site of the declaration of _LocalDirectory.
1 parent bc6ce1f commit ed47cc0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/src/forwarding/forwarding_directory.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
part of file.src.forwarding;
66

77
/// A directory that forwards all methods and properties to a delegate.
8-
abstract class ForwardingDirectory
9-
extends ForwardingFileSystemEntity<Directory, io.Directory>
10-
implements Directory {
8+
abstract class ForwardingDirectory<T extends Directory>
9+
extends ForwardingFileSystemEntity<T, io.Directory> implements Directory {
1110
@override
12-
ForwardingDirectory wrap(io.Directory delegate) => wrapDirectory(delegate);
11+
T wrap(io.Directory delegate) => wrapDirectory(delegate);
1312

1413
@override
1514
Future<Directory> create({bool recursive: false}) async =>

0 commit comments

Comments
 (0)