Wie kann def someA
(in trait B
) trait A
mit dem gleichen C#MyType
wie in B
? (Dann A#MyType =:= B#MyType
)Kuchen Muster und Typen
trait C {
type MyType
}
trait A {
self: C =>
def doSomething(s: MyType) { println(s.toString)}
}
trait B {
self: C =>
def someA: A
def myType: MyType
def action = someA.doSomething(myType)
}
// Mix part
case class Ahoy(value: String)
trait ConcreteC extends C {
type MyType = Ahoy
}
class PieceOfCake extends B with ConcreteC {
val someA = new A with ConcreteC
val myType = Ahoy("MyType")
}
Es lässt sich nicht kompilieren: Typenkonflikt;
[error] found : B.this.MyType
[error] required: _1.MyType where val _1: A
[error] def action = someA.doSomething(myType))
Ok, es kompiliert, aber Sie können nicht einen bestimmten SomeType mit B mischen. – jwinandy