In Haskell, we call this problem "overlapping instances," and can be allowed with an optional compiler flag. Nevertheless, I try to avoid using it, because of the potential for unforeseen consequences and reduced clarity in which code is actually being run.
In this use case, my instinct tells me that trait specialization is the wrong tool for the job. The author is trying to dispatch different functions based on a flag set in the caller. I can think of two more elegant ways to do this:
* Make the file system itself a trait, with implementations for read-only and read/write. Pass the concrete implementation as a parameter to the function using it.
* Store the capabilities as a variable in the file system object and query it at runtime. This can be done with an if.
Sometimes the simpler approach is better.