Given the simple example source I need to be able to create a copy constructor and implicit conversion method. Can somebody please advice how to achieve this with Scala 2.10 and new macros feature?
import java.util.UUID
object Sample {
case class Entity(id: UUID, name: String)
trait Storable {
val storageId: UUID
}
trait Storage {
type T <: Entity with Storable
def save(src: T) : T
}
class StorageImpl extends Storage {
type T = Entity with Storable
def save(src: StorageImpl#T): StorageImpl#T = null
}
def getEntity() = Entity(UUID.randomUUID(), "Test")
def main(args: Array[String]) {
val storage = new StorageImpl
val entity = getEntity() // get this from some third-party module
storage.save(entity) // HOW?! Create copy constructor and implicit?
}
}