This will work as-is when called from inside an ordinary instance of a class, so I'll assume you're trying it from inside an object, in which case you'll need to match against ModuleDef as well as ClassDef:

case ModuleDef(mods, name, impl) => c.universe.reify(
    "\n  mods %s\n  name %s\n  impl %s\n",

Note that one easy way to debug something like this is to print out the raw representation of whatever unexpected thing you're getting:

case x => c.abort(c.enclosingPosition, "NoEnclosingClass: " + showRaw(x))

This would print the following when called inside a singleton object:

<console>:7: error: NoEnclosingClass: ModuleDef(Modifiers(), ...

Which gives us a pretty good idea of where we need to start.

Related Query

More Query from same tag