简体   繁体   中英

scala macro how to infer implicit CanBuildFrom

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)

I am trying to infer an implicit CanBuildFrom .

But the cbf I got is empty tree ?

How can I get the implicit instance of CanBuildFrom in a scala macro?

您需要编写typeOf[List[_]]而不是typeOf[List[_]].typeConstructorhttps : typeOf[List[_]].typeConstructor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM