[edit update] this is a proper statment of my problem.
I hope to call the constructor inside a trait
.
But it seems I have to use apply
function. does it exist usage like new this()?
Like the code below. It throws type mismatch. I hope to add constraint of constructor, or I have to use apply
function.
trait B { this:C =>
def values:Seq[Int]
def apply(ints:Seq[Int]):this.type
def hello:this.type = apply( values map (_ + 1) )
}
trait C
class A(val v:Seq[Int]) extends C with B{
override def values: Seq[Int] = v
override def apply(ints: Seq[Int]): A.this.type = new A(ints)
}