KamchatkaLtd / okasaki

Scala implementation of data structures from Chris Okasaki's book
41 stars 6 forks source link

The RedBlackSetSpec #6

Open alf239 opened 9 years ago

alf239 commented 9 years ago

SetSpec's val set has a type of Set[E, S]; what I would like to see is something more like SES <: Set[E, S] — but this breaks compilation somehow.

The offending code is:

object RedBlackSetSpec {
  val set = new RedBlackSet[Int]
}

class RedBlackSetSpec
  extends SetSpec(RedBlackSetSpec.set)
  with IntElements {

  val set = RedBlackSetSpec.set

  // ...
}

the ideal code would be something along the lines of,

class RedBlackSetSpec
  extends SetSpec(new RedBlackSet[Int])
  with IntElements {

  // ...
}
alf239 commented 9 years ago

Asked on StackOverflow: http://stackoverflow.com/questions/32279385/generic-inheritance-in-scala