emchristiansen
emchristiansen

Reputation: 3612

Implicit macros not found in Scala 2.10.1?

It seems like the implicit keyword doesn't work when applied to macro defs.

For example, take the following code:

// Compilation unit A:
case class Foo[A]
// end A.

// Compilation unit B:
implicit def implicitFoo[A]: Foo[A] = macro implicitFoo_impl[A]

def implicitFoo_impl[A](c: Context): c.Expr[Foo[A]] =
  c.universe.reify(Foo[A])
// end B.

// Compilation unit C:
implicitly[Foo[Int]] // Fails with "could not find implicit value for parameter e: Foo[Int]
// end C.

The implicitly[Foo[Int]] fails, but it shouldn't; if I replace implicit def implicitFoo[A]: Foo[A] = macro implicitFoo_impl[A] with implicit def implicitFoo[A]: Foo[A] = ???, compilation succeeds.

Is this a bug or user error?

Upvotes: 2

Views: 212

Answers (1)

Eugene Burmako
Eugene Burmako

Reputation: 13048

This is caused by https://issues.scala-lang.org/browse/SI-5923, which is fixed in master (2.11.0-SNAPSHOT), and which I'm planning to backport to 2.10.2. See more information (including potential problems which might prevent me from making it in time for 2.10.2) on the aforementioned JIRA page.

Upvotes: 4

Related Questions