Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Encoder {
- implicit def apply[R <: Product]: Encoder[R] = macro applyImpl[R]
- def applyImpl[R: c.WeakTypeTag](c: blackbox.Context): c.Expr[Encoder[R]] = {
- import c.universe._
- c.Expr[Encoder[R]](q"""
- new ${weakTypeOf[Encoder[R]]} {
- override def encode(r: ${weakTypeOf[R]}): Array[Byte] =
- implicitly[_root_.Serializer[${weakTypeOf[R]}]].serialize(r)
- }
- """)
- }
- }
- case class Record(i: Int)
- object Serializers {
- implicit def recordSerializer: Serializer[Record] =
- (r: Record) => Array.emptyByteArray
- }
- import Serializers._
- class Processor extends BaseProcessor[Record]
- // [error] Loader.scala:10:22: could not find implicit value for parameter e: Serializer[Record]
- // [error] class Processor extends BaseProcessor[Record]
- // [error] ^
- // [error] one error found
- object x {
- import Serializers._ // moving the import here also makes it NOT compile
- class Processor extends BaseProcessor[Record]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement