Skip to content

Instantly share code, notes, and snippets.

@sihil
Created November 19, 2012 16:55
Show Gist options
  • Save sihil/4111838 to your computer and use it in GitHub Desktop.
Save sihil/4111838 to your computer and use it in GitHub Desktop.
Type hinting when necessary doesn't seem to work for traits...
import com.novus.salat._
import com.novus.salat.global.ctx
import com.mongodb.casbah.commons.MongoDBObject
trait TestTrait
case class Test(value: TestTrait)
case class ValueType(number: Int) extends TestTrait
object TestGraters {
val testGrater = grater[Test]
val testInstance = Test(ValueType(1))
def tryToSerialise(): Test = {
val gratedDocument = testGrater.asDBObject(testInstance)
testGrater.asObject(new MongoDBObject(gratedDocument))
}
}
@sihil
Copy link
Author

sihil commented Nov 19, 2012

Produces a com.novus.salat.util.MissingTypeHint [NO TYPE HINT FOUND!\n\n Expected type hint key: _typeHint\n\n MAP-LIKE:\n string -> bob]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment