0

While debuging macro annotation IntelliJ throws this error:

test\UseMacro.scala:7: error: macro annotation could not be expanded (the most common reason for that is that you need to enable the macro paradise plugin; another possibility is that you try to use macro annotation in the same compilation run that defines it)
@identity class Test

I have the main project that uses macro subproject (macroSub). Macro project defines simple @identity macro and the main project uses this one with UseMacro.scala

build.sbt:

lazy val commonSettings = Seq(
  version := "1.0",
  scalaVersion := "2.11.7"
)

lazy val root = (project in file(".")).
  dependsOn(macroSub).
  enablePlugins(PlayScala).
  settings(commonSettings: _*).
  settings(
    name := "root",
    resolvers ++= Seq(
      "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/",
      "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
    ),
    libraryDependencies ++= Seq(
      "com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT",
      "com.typesafe.akka" %% "akka-agent" % "2.4-SNAPSHOT"
    )
  )

lazy val scalaReflect = Def.setting { "org.scala-lang" % "scala-reflect" % scalaVersion.value }

lazy val macroSub = (project in file("macro")).
  settings(commonSettings: _*).
  settings(
    resolvers ++= Seq(
      Resolver.sonatypeRepo("releases")
    ),
    libraryDependencies += scalaReflect.value,
    libraryDependencies += compilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full),
    addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
  )

I can successfuly debug normal macros but when i create a macro annotation i have this kind of error. What should i to do with my intellij configuration and build.sbt to solve that problem and debug macro annotations?

Daryl
  • 644
  • 1
  • 9
  • 20

1 Answers1

0

I was not able to configure IntelliJ to get Macro debugging to run at all in my project, but I found a much easier solution by trudolf that also works fine with macro annotations:

  • start sbt with: sbt -jvm-debug 5005
  • create a "Remote" "Run/Debug Config" in idea (defaults to port 5005)

Run the remote-debug config in idea. That will connect it to your running sbt. Then you can set breakpoints in your macro code and when running compile in sbt, idea should stop at the breakpoint.