New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to specify type arguments in ClassMirror.newInstance #12921
Comments
Added Area-Library label. |
One issue is how we get a class mirror for a given instantiation in the first place. Maybe have an optional argument to reflectClass that is a list of type arguments. The newInstance doesn't have to deal with the problem. Added Accepted label. |
Issue #21009 has been merged into this issue. |
This comment was originally written by @jonaskello Type arguments to reflectClass sounds good to me. My scenario is Message/Handler. Something like this: Using di package to bind Types to implementation: bind(TypeLiteral<IMessageHandler<FooMessage>>, toImplementation: FooMessageHandler); When I then receive a message I want to be able to dynamically construct a Type for the handler of the message received. If reflectClass had type arguments I guess I could do something like this: var msg = ReceiveMessage(); I'm also be interested in work-arounds or alternatives that would solve this scenario in the current version. |
This comment was originally written by @jonaskello Yes I think this is a basic function that should have been added long ago. Maybe it is because the title is a bit off. In general I think requests that are formulated as a problem description is better than those formulated as a proposed solution. Maybe something like "Cannot get class mirror for generic instantiation when type arguments are not known until runtime." Should we create a new issue? |
Is this something that requires DEP or can be implemented and submitted in a PR? |
I believe this is subsumed by the feature proposed in #26012 (even though that issue says at first that it isn't). |
I think we can close this since it's covered by type arguments in |
Maybe?
Or maybe specify that the same arguments from the ClassMirror will be used if it is a mirror on an instantiated generic and all dynamic otherwise?
The text was updated successfully, but these errors were encountered: