何が入っているかに基づいて特定のデータ型を返すことは可能ですか?のは、私は次のコードを持っているとしましょう:T
はSpecificA
と同様にB
のためであればスカラの入力パラメータタイプに基づいて戻り値の型を制限する
sealed trait Super
case class SpecificA(...) extends Super
case class SpecificB(...) extends Super
trait Bells
trait Whistles
sealed trait Something
case class SomeAWithBellsAndWhistles(...) extends Something with Bells with Whistles
case class SomeBWithBellsAndWhistles(...) extends Something with Bells with Whistles
object Utils {
def doStuff[T <: Super](...): RT
}
RT
しかSomeAWithBellsAndWhistles
することができます。私がすべての「許可された」組み合わせを知っているなら、それを強制する方法はありますか?