class A extends B with C {
super[B].superFunc()
super[C].superFunc()
}
trait D {
def getSomething: String
def superFunc: /* some code */ getSomething() /* some more code */
}
trait B extends D {
def getSomething: String = "hello"
}
trait C extends D {
def getSomething: String = "world"
}
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I understand your example but if you read my question, it is related more to how functions are inherited from multiple traits when there are naming conflicts than just simply overriding a method. Your example is very straightforward and does not capture any of the intricacies of my question.
If I understand you correctly, do you mean when I call super[B].superFunc(), it is actually calling the getSomething function from C because of linearization? That seems like a very unintuitive way to define functionality in a language. As far as I understand it, scala tries to be very functional and this does not seem to be something that is line with that type of thinking.
trait D {
def getSomething: String
def superFunc: String = getSomething
}
trait B extends D {
override def getSomething: String = "hello"
}
trait C extends D {
override def getSomething: String = "world"
}
class A extends B with C {
def makeStringUsingSuperFunc: String = super[B].superFunc + super[C].superFunc
def makeString: String = super[B].getSomething + super[C].getSomething
}
val a = new A