Skip to content

Typechecking of a macro expansion infers wrong type for List.map #6155

@scabug

Description

@scabug

As per http://stackoverflow.com/questions/11681631/macro-return-type-and-higher-order-functions:

Macro definition:

def test(s:String) = macro testImpl

def testImpl(c:Context)(s:c.Expr[String]):c.Expr[Any] = {
  import c.universe._
  val list = reify(List(1)).tree

  val function = reify((x:Int) => x).tree

  val res = 
    Apply(
      Select(
        list,
        newTermName("map")),
      List(function)
    )

  c.Expr(res)
}

Macro call:

val list:List[Int] = test("")

Error message:

[error]  found   : Any
[error]  required: List[Int]
[error]     val list:List[Int] = test("")
[error]                              ^

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions