Skip to content

Method in trait not a legal implementation in inheriting class #4819

Closed
@allanrenucci

Description

@allanrenucci
trait Iterable[+A]

trait IterableOps[+A, +CC[_], +C] {
  def concat[B >: A](suffix: Iterable[B]): CC[B] = ???
}

trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]]  {
  def concat(that: Iterable[A]): C = ???
}

class ChampHashSet[A] extends SetOps[A, ChampHashSet, ChampHashSet[A]] with
    IterableOps[A, ChampHashSet, ChampHashSet[A]]
-- Error: tests/allan/Test.scala:15:6 ------------------------------------------
15 |class ChampHashSet[A] extends SetOps[A, ChampHashSet, ChampHashSet[A]] with
   |      ^
   |method concat in trait IterableOps is not a legal implementation of `concat' in class ChampHashSet
   |  its type             [B >: A](suffix: Iterable[B]): ChampHashSet[B]
   |  does not conform to  (that: Iterable[A]): ChampHashSet[A]
one error found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions