Method in trait not a legal implementation in inheriting class (V2)
See original GitHub issuepackage collection
trait Map[K, +V] extends MapOps[K, V, Map]
trait MapOps[K, +V, +CC[_, _]] {
def collect[K2, V2](pf: PartialFunction[(K, V), (K2, V2)]): CC[K2, V2] = ???
}
trait SortedMapOps[K, +V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC]]
extends MapOps[K, V, Map]
trait StrictOptimizedMapOps[K, +V, +CC[_, _]] extends MapOps[K, V, CC] {
override def collect[K2, V2](pf: PartialFunction[(K, V), (K2, V2)]): CC[K2, V2] = ???
}
trait StrictOptimizedSortedMapOps[K, +V, +CC[X, Y] <: Map[X, Y] with SortedMapOps[X, Y, CC]]
extends SortedMapOps[K, V, CC] with StrictOptimizedMapOps[K, V, Map]
package immutable {
trait Map[K, +V] extends collection.Map[K, V] with MapOps[K, V, Map]
trait MapOps[K, +V, +CC[X, +Y] <: MapOps[X, Y, CC]] extends collection.MapOps[K, V, CC]
trait SortedMapOps[K, +V, +CC[X, +Y] <: Map[X, Y] with SortedMapOps[X, Y, CC]]
extends MapOps[K, V, Map] with collection.SortedMapOps[K, V, CC]
class TreeMap[K, +V] extends Map[K, V] with SortedMapOps[K, V, TreeMap]
with StrictOptimizedSortedMapOps[K, V, TreeMap]
}
-- Error: tests/allan/Test.scala:86:8 ------------------------------------------
86 | class TreeMap[K, +V] extends Map[K, V] with SortedMapOps[K, V, TreeMap]
| ^
|method collect in trait StrictOptimizedMapOps is not a legal implementation of `collect` in class TreeMap
| its type [K2, V2](pf: PartialFunction[(K, V), (K2, V2)]): collection.Map[K2, V2]
| does not conform to [K2, V2]
| (pf: PartialFunction[(K, V), (K2, V2)]): collection.immutable.Map[K2, V2]
one error found
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Implementing an abstract method with a trait, inconsistent ...
The real key to the power of traits is the way in which the compiler treats them in an inheriting class. Traits are...
Read more >Scala Traits vs. Abstract Classes - Baeldung
Traits are used to group methods for a given behavior. Just like abstract classes they can have fully defined and not implement methods....
Read more >The Practical Difference Between Abstract Classes and Traits ...
This short article will compare abstract classes and traits as means of inheritance.
Read more >Are default trait method implementations as reusable ... - Reddit
In The Book, Ch 17.1 argues against the use of inheritance. It states that inheritance is good for two things: 1. Reuse code...
Read more >Classes & Objects | Scala 2.13
Finally, a template is not allowed to contain two methods (directly defined or inherited) with the same name which both define default arguments....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Opened https://github.com/scala/bug/issues/11042 to track a related soundness bug in scalac.
Closing as the bug was not in Dotty and the library was fixed — @allanrenucci correct me if I’m wrong.