Scala Programming Language
  1. Scala Programming Language
  2. SI-5744

macro defs effectively cannot have context bounds

    Details

      Description

      import scala.reflect.makro.{Context => Ctx}
      
      object Impls {
        def foo[U](c: Ctx)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = {
          import c.mirror._
          val plusOne = Apply(Select(evidence.tree, newTermName("plus")), List(x.tree, Literal(Constant(1))))
          val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne))
          Expr[Unit](body)
        }
      }
      
      object Test extends App {
        def foo[U: Numeric](x: U) = macro Impls.foo[U]
        foo(42)
      }
      
      Macros_Test_2.scala:2: error: macro implementation has wrong shape:
       required: (c: scala.reflect.makro.Context)(x: c.Expr[U])(evidence$1: c.Expr[Numeric[U]]): c.Expr[Unit]
       found   : (c: scala.reflect.makro.Context)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]): c.Expr[Unit]
      parameter names differ: evidence$1 != evidence
        def foo[U: Numeric](x: U) = macro Impls.foo[U]
                                                   ^
      one error found
      

        Activity

        Hide
        Eugene Burmako added a comment -

        Synthetic evidence ValDefs should be marked as SYNTHETIC. In that case macro def <-> macro impl correspondence checker will ignore the names.

        Show
        Eugene Burmako added a comment - Synthetic evidence ValDefs should be marked as SYNTHETIC. In that case macro def <-> macro impl correspondence checker will ignore the names.
        Hide
        Eugene Burmako added a comment -

        This issue is being fixed.

        Show
        Eugene Burmako added a comment - This issue is being fixed.
        Show
        Eugene Burmako added a comment - https://github.com/scala/scala/pull/2074
        Hide
        James Iry added a comment -
        Show
        James Iry added a comment - superseded by https://github.com/scala/scala/pull/2086
        Hide
        James Iry added a comment -

        2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

        Show
        James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
        Hide
        Jason Zaugg added a comment -

        I believe that we forgot to close this ticket for 2.10.2; doing so now.

        Show
        Jason Zaugg added a comment - I believe that we forgot to close this ticket for 2.10.2; doing so now.

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development