Allowing a type parameter to extend more than one type. #3960
Labels
feature
Proposed language feature that solves one or more problems
state-duplicate
This issue or pull request already exists
I have the following classes while building a package to abstract reading of different sources:
ReadMixin on DataSource
, which provides a read() method.SeekMixin on DataSource
, which provides a seek(position) method.Some DataSources, for example one wrapping a file implement both.
Is there currently a way to define a function which accepts a DataSource which implements Both mixins? I would expect somethhing like this to work:
T myFunction<T extends ReadMixin with SeekMixin>(T param) {}
but it does not.
I have found similar issues asking for a similar concepts but for unrelated types, like #2161 (
String
andIterable<String>
), but I have not found an issue talking about 'related' types, like what I am trying to achieve.Is there currently a way to do this?
The text was updated successfully, but these errors were encountered: