2

The compiler is throwing me a 'Missing parameter type'. After cornering the problem I've realized that when chaining Partial Functions you need to be explicit about the types or the compiler will throw the mentioned error. Now, do you guys know if there are any issues when chaining partial functions inside a macro's reify? I think I couldn't be more explicit about the partial function types:

object Implementations{
      def missingParamType_impl(c: whitebox.Context)(a: c.Expr[Int]):c.Expr[PartialFunction[Int,String]] = {
        import c.universe._

        reify {
          val spliced = a.splice
          val spliced2 = a.splice * 2
          ((PartialFunction.apply[Int,String]{
            case `spliced` ⇒ a.splice.toString
          } : PartialFunction[Int,String]).orElse[Int,String]{
            case `spliced2` ⇒ a.splice.toString
          } : PartialFunction[Int,String]) : PartialFunction[Int,String]
        }
      }
}

This is how I call the macro implementation:

object Macros {
def missingParamType(a: Int):PartialFunction[Int,String] = macro Implementations.missingParamType_impl
}

I have also tried this:

def missingParamType_impl(c: whitebox.Context)(a: c.Expr[Int]):c.Expr[PartialFunction[Int,String]] = {
    import c.universe._

    reify {
      val spliced = a.splice
      val spliced2 = a.splice * 2
      val pf1: PartialFunction[Int, String] = {
        case `spliced` ⇒ a.splice.toString
      }
      val pf2: PartialFunction[Int, String] = {
        case `spliced2` ⇒ a.splice.toString
      }
      val PF:PartialFunction[Int, String] = pf1.orElse(pf2)
      PF
    }
  }

Or am I fundamentally misunderstanding how reify works?

2
  • How much of a blocker is this for you? Commented Feb 26, 2015 at 8:15
  • Not really. I think a map will do the job Commented Feb 26, 2015 at 9:58

1 Answer 1

1

Unfortunately, this looks like a known issue: https://issues.scala-lang.org/browse/SI-6619.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.