score:0

It can be easier done if you can use abstract class, like this:

abstract class Filter[RequiredType<:BaseType:Manifest] {
   def isOfRequiredType[A <: BaseType](aObj: A): Boolean = 
       manifest[RequiredType].runtimeClass.isAssignableFrom(aObj.getClass)       

   ...
}

The code above uses manifests - which are supposed to be replaced with TypeTags in the future, howeve I don't have to much experience with this part of scala 2.10 so I stick with manifest version for now.

https://groups.google.com/forum/#!msg/scala-user/2X7pHwqd6_A/fOd1yyURIhEJ - here is discussion why it's not so easy with traits.


Related Query

More Query from same tag