The situation I'm facing is one where I need to instantiate a class by name, but that class is actually a scala type alias defined in an object (a package object actually). I have figured out many piece of what I need for this, but I can't find a way to introspect the object to get the type aliases.
Specifically, I have the string "Foo.MyString" and I want to instantiate an instance of that based on the following definition.
object Foo {
type MyString = String
}
I can use runtimeMirror.staticModule
to get the symbol, and then runtimeMirror.reflectModule
, but I can't find any way to then resolve the type alias name of "MyString".
To get the methods or fields of Foo I can drop down to Java introspection with module.instance.getClass, but Java obviously doesn't have a way to get the type aliases.
I've also tried using Symbols, but that just let's you get the owner of a symbol, not the 'owned' symbol.
Aucun commentaire:
Enregistrer un commentaire