Skip to content

Instantly share code, notes, and snippets.

@dstu
Created April 21, 2014 20:13
Show Gist options
  • Save dstu/11155020 to your computer and use it in GitHub Desktop.
Save dstu/11155020 to your computer and use it in GitHub Desktop.
Dead code error in Scala macro definintion
package errordemo
import scala.annotation.StaticAnnotation
import scala.reflect.macros.whitebox.Context
class mymacro extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro MacroImpl.macroImpl
}
class MacroImpl(val c: Context) {
import c.universe._
def macroImpl(annottees: c.Expr[Any]*): c.Expr[Any] = c.literalUnit
}
@dstu
Copy link
Author

dstu commented Apr 21, 2014

Scala 2.11.0, macroparadise 2.0.0, sbt 0.13.2. Error message: "dead code following this construct" at "macro MacroImpl.macroImpl".

@dstu
Copy link
Author

dstu commented Apr 22, 2014

NB: This crops up as an error when -Ywarn-dead-code and -Xfatal-warnings are passed to scalac. The warning is spurious, and a patch has been written. This should be fixed in Scala 2.11.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment