Created
January 23, 2013 03:18
-
-
Save mgonto/4601597 to your computer and use it in GitHub Desktop.
Scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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