I am experimenting with implicit variables in my Scala code. I wrote the following sample code but unfortunately it fails to compile. I was wondering, does anybody know what is missing here ? (using scala 2.8.0 with SBT 0.7.4 on linux)
Thanks,
Ali
trait Feed
trait FeedFactory {
type T <: Feed
implicit val op_name = classOf[T].getCanonicalName
def create():T
def destroy(op:T)
}
Error: class type required but FeedFactory.this.T found
implicit val op_name = classOf[T].getCanonicalName
type T is forgotten at compile time (see type erasure). But scala offers
Manifests that retain type through compilation.Here is a more complete explanation.