risposta

16

Usare un auto-tipo:

scala> trait Foo { self => type A <: Foo {type A = self.A}} 
defined trait Foo 

scala> class Bar extends Foo { type A = Bar } 
defined class Bar 

scala> class Bar extends Foo { type A = Int } 
<console>:10: error: overriding type A in trait Foo with bounds <: Foo{type A = Bar.this.A}; 
type A has incompatible type 
     class Bar extends Foo { type A = Int } 
            ^
+0

Questa era la mia intuizione originaria, grande risposta! –