Last active
December 18, 2015 02:48
-
-
Save Sciss/5713325 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import reflect.runtime.{universe => ru} | |
| val m = ru.runtimeMirror(getClass.getClassLoader) | |
| case class Bar(i: Int) | |
| val tpe = ru.typeOf[Bar] | |
| val classBar = tpe.typeSymbol.asClass | |
| val cm = m.reflectClass(classBar) | |
| val ctor = tpe.declaration(ru.nme.CONSTRUCTOR).asMethod | |
| val ctorm = cm.reflectConstructor(ctor) | |
| val p = ctorm(33) | |
| // figuring out arg types | |
| val arg1 = ctor.paramss.head.head | |
| arg1.typeSignature =:= ru.typeOf[Int] // true. is there a simpler way? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment