Let imagine I have the following traits/classes hierarchy ( scala 2.13 )
trait In
trait Out
case class In1() extends In
case class In2() extends In
case class Out1() extends Out
case class Out11() extends Out
case class Out2() extends Out
I'd like to write function that:
- In the case where
In1
was sent as a param will only allow the return ofOut1
orOut11
object - In the case where
In2
was sent as a param will only allow the return ofOut2
object - Will check it on compile time
Unfortunately, I wasn't able to achieve it on my own even using external libs.
Could you please help or clarify if it possible at all ?