Skip to content

The mirrors library does not understand extensions #43086

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

Closed
lrhn opened this issue Aug 18, 2020 · 1 comment
Closed

The mirrors library does not understand extensions #43086

lrhn opened this issue Aug 18, 2020 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-mirrors type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Aug 18, 2020

The dart:mirrors library has no notion of extensions.

It doesn't expose an extension declaration as a member of the library it's declared in. Instead it exposes the synthetic top-level declarations that the extension is desugared into. Exposing those is definitely wrong.

Example:

library name;
import"dart:mirrors";

extension Foo<T> on T {
  static int foo() => 42;
  T get log {
    print(this); 
    return this;
  }
}

main() {
 var library = reflectClass(Hook).owner as LibraryMirror;
 print("Library name: ${library.simpleName}"); // Sanity check, it's the current library.
 print("Library declares Foo: ${library.declarations[#Foo]}"); // No
 print("Library leaks Foo.log: ${library.declarations[#Foo.log]}"); // Yes, it does.
 print("Library leaks Foo.foo: ${library.declarations[#Foo.foo]}"); // Yes, it does.
}
class Hook {}

The mirrors library should either be deprecated or be made compatible with new language features.

@lrhn lrhn added 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 labels Aug 18, 2020
@a-siva
Copy link
Contributor

a-siva commented Aug 5, 2022

At this point we have no plans for enhancing the dart:mirrors library to account for new language features.
Please see #44489 which is investigating a path towards discontinuing support for dart:mirrors

@a-siva a-siva added the closed-not-planned Closed as we don't intend to take action on the reported issue label Aug 5, 2022
@a-siva a-siva closed this as completed Aug 5, 2022
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-not-planned Closed as we don't intend to take action on the reported issue library-mirrors type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants