Skip to content
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

Closed
rmacnak-google opened this issue Aug 30, 2013 · 8 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-mirrors type-enhancement A request for a change that isn't a bug

Comments

@rmacnak-google
Copy link
Contributor

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?

@lrhn
Copy link
Member

lrhn commented Aug 30, 2013

Added Area-Library label.

@gbracha
Copy link
Contributor

gbracha commented Aug 31, 2013

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.

@floitschG
Copy link
Contributor

Issue #21009 has been merged into this issue.

@DartBot
Copy link

DartBot commented Oct 22, 2014

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);
bind(TypeLiteral<IMessageHandler<BarMessage>>, toImplementation: BarMessageHandler);

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();
var handlerType = reflectClass(IMesssageHandler, msg.runtimeType);
var handler = injector.get(handlerType);
handler.Handle(msg);

I'm also be interested in work-arounds or alternatives that would solve this scenario in the current version.

@DartBot
Copy link

DartBot commented Oct 23, 2014

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?

@rmacnak-google rmacnak-google added Type-Enhancement library-mirrors area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Oct 23, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@pulyaevskiy
Copy link
Contributor

Is this something that requires DEP or can be implemented and submitted in a PR?

@eernstg
Copy link
Member

eernstg commented Aug 12, 2016

I believe this is subsumed by the feature proposed in #26012 (even though that issue says at first that it isn't).

@natebosch
Copy link
Member

I think we can close this since it's covered by type arguments in reflectType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-mirrors type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants