scala - Manifest error for anonymous type -
i still getting head around scala, trying figure out missing in below code. getting error message when try instantiate genericserializer anonymous type
description resource path location type type mismatch; found : scala.reflect.manifest[object] required: scala.reflect.manifest[foldermgmtdao.this.anomovetype] note: object >: foldermgmtdao.this.anomovetype, trait manifest invariant in type t. may wish investigate wildcard type such
_ >: foldermgmtdao.this.anomovetype
. (sls 3.2.10) foldermgmtdao.scala /somucore/src/somu/core line 20 scala problem
below code
object genericserializer { def apply[t <:anyref:manifest]() = new genericserializer[t]() } class genericserializer[t <:anyref:manifest] extends imongoserializer[t] {} //anonymous type creation , using genericserializer type anomovetype = { def folderpath:string } val szr = genericserializer[anomovetype]
looks like it's not possible manifests. should use typetag
instead. this:
import scala.reflect.runtime.universe._ object genericserializer { def apply[t <:anyref]()(implicit tag: typetag[t]) = {} }
Comments
Post a Comment