{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/23896","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/23896/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/23896/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/23896/events","html_url":"https://github.com/dart-lang/sdk/issues/23896","id":96635603,"number":23896,"title":"Runtime dynamic object/real proxy","user":{"login":"BlackHC","id":729312,"avatar_url":"https://avatars.githubusercontent.com/u/729312?v=3","gravatar_id":"","url":"https://api.github.com/users/BlackHC","html_url":"https://github.com/BlackHC","followers_url":"https://api.github.com/users/BlackHC/followers","following_url":"https://api.github.com/users/BlackHC/following{/other_user}","gists_url":"https://api.github.com/users/BlackHC/gists{/gist_id}","starred_url":"https://api.github.com/users/BlackHC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlackHC/subscriptions","organizations_url":"https://api.github.com/users/BlackHC/orgs","repos_url":"https://api.github.com/users/BlackHC/repos","events_url":"https://api.github.com/users/BlackHC/events{/privacy}","received_events_url":"https://api.github.com/users/BlackHC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-22T18:38:18Z","updated_at":"2015-07-22T18:51:20Z","closed_at":null,"body":"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.\r\n\r\n```\r\n// Implements every interface in regard to type-checks\r\nclass Forwarder implements dynamic {\r\n  final _delegate;\r\n\r\n  Forwarder(this._delegate);\r\n\r\n  noSuchMethod(invocation) => ...;\r\n}\r\n```\r\n```\r\nForwarder forwarder = new Forwarder('hello');\r\nString a = forwarder;\r\nassert(a.runtimeType == Forwarder);\r\nassert(a is String);\r\n```\r\n\r\nForwarder is effectively dynamic. Currently, this only works for generic parameters in type checks.\r\n(`print(new List<dynamic>() is List<String>); // prints true`).\r\n\r\nAn 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.\r\n\r\nCurrently, 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."},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/123825761","html_url":"https://github.com/dart-lang/sdk/issues/23896#issuecomment-123825761","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/23896","id":123825761,"user":{"login":"seaneagan","id":444270,"avatar_url":"https://avatars.githubusercontent.com/u/444270?v=3","gravatar_id":"","url":"https://api.github.com/users/seaneagan","html_url":"https://github.com/seaneagan","followers_url":"https://api.github.com/users/seaneagan/followers","following_url":"https://api.github.com/users/seaneagan/following{/other_user}","gists_url":"https://api.github.com/users/seaneagan/gists{/gist_id}","starred_url":"https://api.github.com/users/seaneagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seaneagan/subscriptions","organizations_url":"https://api.github.com/users/seaneagan/orgs","repos_url":"https://api.github.com/users/seaneagan/repos","events_url":"https://api.github.com/users/seaneagan/events{/privacy}","received_events_url":"https://api.github.com/users/seaneagan/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T18:51:20Z","updated_at":"2015-07-22T18:51:20Z","body":"Isn't that what [@proxy](https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:core#id_proxy) is for?"}}