1

我正在尝试将宏从 Scala 2.10 移植到 2.11.0-M7:

import scala.reflect.macros.Context

object Format {
  def apply[A]: Unit = macro applyImpl[A]

  def applyImpl[A: c.WeakTypeTag](c: Context): c.Expr[Unit] = ???
}

一定有什么改变了,因为编译器说不scala.reflect.macros.Context存在。

我的构建文件如下所示:

scalaVersion := "2.11.0-M7"

resolvers += Resolver.sonatypeRepo("snapshots")

addCompilerPlugin("org.scala-lang.plugins" % "macro-paradise" % "2.0.0-SNAPSHOT"
  cross CrossVersion.full)

有什么线索吗?

4

1 回答 1

5

现在需要明确添加scala-reflect

libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value

Context已弃用,但可以编译。

于 2013-12-10T09:12:46.350 回答