scala> object O
defined module O
scala> def impl[T: c.WeakTypeTag](c: Context): c.Expr[Class[_]] = {import c.universe._; c.Expr[Class[_]](Literal(Constant(weakTypeOf[T])))}
impl: [T](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T])c.Expr[Class[_]]
scala> def moduleClassOf[T <: Singleton]: Class[_] = macro impl[T]
moduleClassOf: [T <: Singleton]=> Class[_]
scala> moduleClassOf[O.type]
res5: Class[O.type] = class O$
I guess that it's something of an accident that this works, but I need to use this trick to fix SI-6259 in a manner more pleasing the the byte code verification police.
This also provides a tenable solution for SI-2453, where I just noticed my ponderings for last year:
> I wonder, could classOf be rewritten these days as a macro?
> How about instanceClassOf / staticClassOf?
Hey, past me: it seems like `instanceClassOf` can!
-jason