Would there be any way in scala, to define a trait's self type to be a case class, as in "any case class"? I would like a self type to be able to use the .copy
method of a case class, enforcing that its self type is some case class not a regular class. Structural types, I think, won't help, as they require a signature comprising specific arguments (I can probably not structural-type generically for any case class).
Please forgo the "if you need that you must be doing something wrong", as I've already moved on but my api design - will have been slicker if the above were possible. I am also curious for next times around.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…