class TC[T] case class C(nodes: List[C]) import language.experimental.macros import reflect.macros.blackbox.Context def impl[T <: C: c.WeakTypeTag](c: Context): c.Expr[TC[T]] = { import c.universe._ def proposal = q"""{ implicit def m: TC[C] = ??? implicitly[TC[List[C]]] ??? }""" println("typechecked: " + c.typeCheck(proposal, silent = true, withMacrosDisabled = true)) c.Expr[TC[T]](proposal) } implicit def m[T <: C]: TC[T] = macro impl[T] implicit def listTC[T: TC]: TC[List[T]] = new TC[List[T]] implicitly[TC[List[C]]] typechecked: <empty> <console>:61: error: diverging implicit expansion for type TC[List[C]] starting with method listTC implicitly[TC[List[C]]]
I believe think the checking is inline with the spec for divergence checking.
However, you can replace blackbox.Context
with whitebox.Context
and the compiler will wash its hands of preventing divergence, and it is up to the implicit macro
author: https://gist.github.com/retronym/8501b1b3b113f4386cda
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.