-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-obsoleteClosed as the reported issue is no longer relevantClosed as the reported issue is no longer relevanttype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
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.
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-obsoleteClosed as the reported issue is no longer relevantClosed as the reported issue is no longer relevanttype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug