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

Add proxy class that can implement interfaces at runtime. #5641

Closed
justinfagnani opened this issue Oct 4, 2012 · 7 comments

Comments

@justinfagnani
Copy link

commented Oct 4, 2012

In unchecked mode it's possible to create objects that implement an interface via noSuchMethod and assign them to a variable or argument of the interface type. This is useful for things like typed proxies for JS interop, automatic stubs for remote/isolated services, etc. In checked mode though assigning to a typed variable causes an exception.

For Proxy, this should work:

var proxy = new Proxy([Foo, Bar]);
assert(proxy is Bar);
assert(proxy is Foo);

Then subclasses can implement behavior.

@gbracha

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2012

We are aware of this issue and intend to resolve it, as these usage patterns are very important. The specific solution suggested here may or may not be what we end up doing.


Set owner to @gbracha.
Added Accepted label.

@DartBot

This comment has been minimized.

Copy link

commented Aug 21, 2013

This comment was originally written by cvl.c...@gmail.com


Is there any progress on this matter?

I use this pattern a lot in my code. For now I do a workaround and introduce a new class for every proxied class but that's cumbersome.

For me to invest more in the dart language, I need to be sure that this is gonna be implemented somehow at some point in the (near) future.

@floitschG

This comment has been minimized.

Copy link
Contributor

commented Nov 4, 2013

Issue #6244 has been merged into this issue.

@justinfagnani

This comment has been minimized.

Copy link
Author

commented Dec 17, 2013

Added C1 label.

@DartBot

This comment has been minimized.

Copy link

commented Jan 2, 2015

This comment was originally written by jirkad...@gmail.com


IMO related:

  • Issue #16638 Allow fine grain control over checked-mode behavior in production and development; Issue #18138
  • and possibly Issue #3049 Contracts; Issue #21984 Structural types
@pulyaevskiy

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2016

Hey team, just curious, the fact that it's not accepted anymore means this will not be implemented?

I am really interested in solution for this use case.

@floitschG

This comment has been minimized.

Copy link
Contributor

commented Dec 20, 2016

@pulyaevskiy:
Sorry for the late response.
As long as the bug is open, it hasn't been rejected. It's not yet high on our TODO lists, and, even when accepted, the outcome might look very different from the proposal here.

TL;DR: we see the need, but we are not currently working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.