Skip to content

Instantly share code, notes, and snippets.

@mgonto
Created January 23, 2013 03:18
Show Gist options
  • Save mgonto/4601597 to your computer and use it in GitHub Desktop.
Save mgonto/4601597 to your computer and use it in GitHub Desktop.
Scanner
nfo] Compiling 2 Scala sources to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/classes...
Children are List()[info]
Compiling 1 Scala source to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/test-classes...
Children are List(class PalObject1, class PalObject2)Children are List(class PalObject1, class PalObject2)0Set()[info]
def subclasses_impl[A: c.WeakTypeTag](c: Context) = {
import c.universe._
val symbol = weakTypeOf[A].typeSymbol
val children = if ((symbol.isClass) && (symbol.asClass.isSealed)) {
symbol.asClass.knownDirectSubclasses.toList //.filter{_.isModuleClass}
} else {
List()
}
print("Children are " + children)
c.Expr[Set[A]](Apply(Select(reify(Set).tree, "apply"), children.map(New(_))))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment