An element of type S in Calc receives shadows due to the parameter of type S the recalc method.
Second mistake: the abstract type S must be defined in the Price class.
The following should work:
sealed trait SeqValue { def seq:Int def value:Float override def toString = ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE) } sealed trait Calc { type S <: SeqValue def recalc(input:S):SeqValue } case class Price(seq:Int=0, value:Float=.0f) extends SeqValue with Calc { type S = SeqValue def recalc(input:SeqValue) = Price(1 + seq, input.value) }
Edit: (in response to the comment)
I donβt understand what exactly you are trying to do, but you can highlight the type definition in a separate mixin attribute.
trait SAsSeqValue { type S = SeqValue } case class Price(seq:Int=0, value:Float=.0f) extends SeqValue with Calc with SAsSeqValue { def recalc(input:SeqValue) = Price(1 + seq, input.value) }
missingfaktor
source share