Interfaces.jl
Interfaces.jl copied to clipboard
Multiple Inheritance
This PR implements multiple inheritance for Interface types storing the inherited types in a second Inherits type parameter of the supertype Interface, and adding dispatch on the second type parameter in the @implements macro so that inheriting types will have a fallback to the inherited types dispatch.
The Inherits parameter can be a Union, so dispatch will work for multiple inherited interfaces. We flatten the inheritance when interfaces are chained (like MyArrayInterface inherits ArrayInterface inherits IterationInterface) so everything is in one Union rather than nested. So the Inherits parameter will be Union{ArrayInterface,IterationInterface} or Union{ArrayInterface{(:some, :options)},IterationInterface}. But the options are stripped by inherited_basetype when Inherits is used for dispatch.
Needs docs and reorganisation/renaming of all the helper methods, it was hard to write so I imagine also hard to understand.
@gdalle if you have time for some feedback, that could help guiding how to document and explain this.
Closes #6
Codecov Report
Attention: Patch coverage is 34.54545% with 36 lines in your changes are missing coverage. Please review.
Project coverage is 74.23%. Comparing base (
071d44f) to head (692b95b).
| Files | Patch % | Lines |
|---|---|---|
| src/interface.jl | 27.58% | 21 Missing :warning: |
| src/implements.jl | 35.00% | 13 Missing :warning: |
| src/test.jl | 66.66% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #43 +/- ##
===========================================
- Coverage 85.11% 74.23% -10.89%
===========================================
Files 5 5
Lines 215 260 +45
===========================================
+ Hits 183 193 +10
- Misses 32 67 +35
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
One caveat here I havent really thought through is that any kind of inheritance necessitates that tests of all inherited interfaces accept the same objects
Mostly I think that will be fine, but may hit problems where mulitiple arguments are used
I'll check this out!
Sorry I did not take the time, will make a pass this week
No worries!