scala宏如何推断隐式CanBuildFrom

时间:2014-07-08 04:17:08

标签: scala scala-macros

val cbfType =
          appliedType(
            typeOf[collection.generic.CanBuildFrom[_, _, _]].typeConstructor,
            typeOf[List[_]].typeConstructor :: typeOf[String] :: typeOf[List[String]] :: Nil
          )
        println(cbfType)
        val cbf = c.inferImplicitValue(cbfType)
        println(cbf)

我试图推断一个隐含的CanBuildFrom

但我得到的cbfempty tree

  

如何在scala宏中获取 CanBuildFrom 的隐式实例?

1 个答案:

答案 0 :(得分:2)

您需要撰写typeOf[List[_]]而不是typeOf[List[_]].typeConstructorhttps://groups.google.com/forum/#!topic/scala-user/724TgGYD7Bs