Scala Macros: Accessing members with quasiquotes

后端 未结 2 583
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 18:31

I\'m trying to implement an implicit materializer as described here: http://docs.scala-lang.org/overviews/macros/implicits.html

I decided to create a macro that converts

2条回答
  •  梦毁少年i
    2021-02-04 19:01

    Ah, figured it out almost immediately after sending my question.

    I changed the lines

    val fields = tpe.declarations.collect {
      case field if field.isMethod && field.asMethod.isCaseAccessor => field.asMethod.accessed
    }
    

    to

    val fields = tpe.declarations.collect {
      case field if field.isMethod && field.asMethod.isCaseAccessor => field.name
    }
    

    which solved the problem.

提交回复
热议问题