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

Runtime dynamic object/real proxy #23896

Closed
BlackHC opened this issue Jul 22, 2015 · 3 comments
Closed

Runtime dynamic object/real proxy #23896

BlackHC opened this issue Jul 22, 2015 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug

Comments

@BlackHC
Copy link
Contributor

BlackHC commented Jul 22, 2015

It is very useful that we can override noSuchMethod and create effective proxies. It would be even more useful if it were possible to create proxies that implement every interface (actual dynamics) when it comes to type checks.

// Implements every interface in regard to type-checks
class Forwarder implements dynamic {
  final _delegate;

  Forwarder(this._delegate);

  noSuchMethod(invocation) => ...;
}
Forwarder forwarder = new Forwarder('hello');
String a = forwarder;
assert(a.runtimeType == Forwarder);
assert(a is String);

Forwarder is effectively dynamic. Currently, this only works for generic parameters in type checks.
(print(new List<dynamic>() is List<String>); // prints true).

An alternative would be to provide a way to mixin classes at runtime, but that would seem much more difficult to implement in the VM/dart2js.

Currently, one has to manually create proxies that implement the right interfaces to avoid runtime errors, which does not scale well for writing generic interceptors/loggers/etc.

@seaneagan
Copy link

Isn't that what @proxy is for?

@BlackHC
Copy link
Contributor Author

BlackHC commented Jul 22, 2015

That does not work. Also even if it were to work as described in the comments, it would only silence static warnings. However, the issue here are runtime errors.

@a14n
Copy link
Contributor

a14n commented Jul 22, 2015

similar to #5641 ?

@sethladd sethladd added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. Type-Enhancement labels Jul 23, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Feb 13, 2018
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. closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants