To avoid having to repeat type parameter information when subclassing parameterized classes, I'm trying to rewrite some code to use abstract types instead.
What I'd like to express is similar to:
class Group[A]
abstract class Thing[A, G <: Group[A]] {
val group: G
}
class SomeGroup[A] extends Group[A] { g =>
object SomeThing extends Thing[A, SomeGroup[A]] {
val group = g
}
}
Using abstract types, my best attempt so far is:
class Group {
type A
}
abstract class Thing { t =>
type A
type G <: Group { type A = t.A }
val group: G
}
class SomeGroup extends Group { g =>
object SomeThing extends Thing {
type A = g.A
type G = SomeGroup { type A = g.A }
val group = g
}
}
However, I'm getting a compiler error on the last line saying "value group has incompatible type".
How can I write the first example using abstract types?