I am trying to modify the Enterprise
trait that extends the StarShip
type.
(I apologize in advance for not knowing a proper title for this but I will update it after I understand the answer.)
For some reason I cannot get the parameters of the starShip
that is passed.
I commented where I am getting the error.
Simple example to demonstrate this:
object Test {
trait Akira extends StarShip
trait Enterprise extends StarShip
sealed trait StarShip {
val captain: String
}
def doSomething[T: StarShip](starShip: T): T =
new T {
val captain = starShip.captain // Error: Cannot resolve symbol
}
doSomething(new Enterprise {
override val captain = "Picard"
})
}
Since I am passing an object of Enterprise
I expect to get the same class out.
Edit:
Just realized that I want all variables in the starShip
that is passed to be copied to the new class. With the exception that I will modify a few of them.
I believe the Monocle lib may solve my problem.