Skip to content

Commit

Permalink
Make ForwardingDirectory generic. (#74)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stereotype441 authored and tvolkert committed Mar 1, 2018
1 parent bc6ce1f commit ed47cc0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/src/forwarding/forwarding_directory.dart
Expand Up @@ -5,11 +5,10 @@
part of file.src.forwarding;

/// A directory that forwards all methods and properties to a delegate.
abstract class ForwardingDirectory
extends ForwardingFileSystemEntity<Directory, io.Directory>
implements Directory {
abstract class ForwardingDirectory<T extends Directory>
extends ForwardingFileSystemEntity<T, io.Directory> implements Directory {
@override
ForwardingDirectory wrap(io.Directory delegate) => wrapDirectory(delegate);
T wrap(io.Directory delegate) => wrapDirectory(delegate);

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

0 comments on commit ed47cc0

Please sign in to comment.