Can a trait override a method in the class it's supposed to be mixed into?

I'd like to do something like:

class C { def x = "foo" }
trait T { this:C => override def x = "bar" }
class C2 extends C with T { println(x) }

I want this to print "bar", but it doesn't compile. Can I make this
work somehow, or do I need to take a completely different approach?

C is a Java class, so I can't make it a trait.

Re: Can a trait override a method in the class it's supposed to

On Wed, Dec 31, 2008 at 10:33:17AM -0600, Seth Tisue wrote:
> I'd like to do something like:
>
> class C { def x = "foo" }
> trait T { this:C => override def x = "bar" }
> class C2 extends C with T { println(x) }

trait T extends C { override def x = "bar" }

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland