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

distinguish static methods from top-level functions in dart2js mirrors #12133

Closed
sigmundch opened this issue Jul 30, 2013 · 11 comments
Closed

distinguish static methods from top-level functions in dart2js mirrors #12133

sigmundch opened this issue Jul 30, 2013 · 11 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@sigmundch
Copy link
Member

In dart2js mirrors, we seem to be including static methods together with top-level methods in the library mirror (this doesn't match the VM behavior). Additionally, the MethodMirror of those methods indicates that the method is topLevel and that declaring owner is the library (rather than the containing class), so it is not possible to distinguish a static method from a top-level method.

To reproduce this problem, take a look at this example:

library foo;
import 'dart:mirrors';

class A {
  static void one() {}
}
void two() { }

main() {
  var lib = currentMirrorSystem().findLibrary(const Symbol('foo')).first;

  print("top-level:");
  lib.functions.forEach((k, v) {
    print('${k}: ${v.simpleName} ${v.isTopLevel}, ${v.owner.simpleName}');
  });

  print("\nin class:");
  lib.classes.values.forEach((c) {
    c.methods.forEach((k, v) {
      print('${c.simpleName}.${k}: ${v.simpleName} ${v.isTopLevel}, ${v.owner.simpleName}');
    });
  });
}

In the VM, this program produces this output:

  top-level:
  Symbol("main"): Symbol("main") true, Symbol("foo")
  Symbol("two"): Symbol("two") true, Symbol("foo")

  in class:
  Symbol("A").Symbol("one"): Symbol("one") false, Symbol("A")

With dart2js, this is the output:

  top-level:
  Symbol("one"): Symbol("one") true, Symbol("foo")
  Symbol("main"): Symbol("main") true, Symbol("foo")
  Symbol("two"): Symbol("two") true, Symbol("foo")

  in class:
  Symbol("main_closure").Symbol("call"): Symbol("call") false, Symbol("main_closure")
  Symbol("main__closure").Symbol("call"): Symbol("call") false, Symbol("main__closure")
  Symbol("A").Symbol("one"): Symbol("one") false, Symbol("A")
  Symbol("main_closure0").Symbol("call"): Symbol("call") false, Symbol("main_closure0")

Note that:
 - "one" is listed in lib.functions
 - such "one" method has [isTopLevel] is true and has "foo" as the owner.
 - some additional classes are shown ("main_closure", etc)

@peter-ahe-google
Copy link
Contributor

Set owner to @peter-ahe-google.
Added Accepted label.

@peter-ahe-google
Copy link
Contributor

Marked this as blocking #6490.

@kasperl
Copy link

kasperl commented Sep 18, 2013

Added this to the M7 milestone.

@peter-ahe-google
Copy link
Contributor

Issue #13733 has been merged into this issue.

@kasperl
Copy link

kasperl commented Oct 2, 2013

Removed this from the M7 milestone.
Added this to the M8 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the M8 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@floitschG
Copy link
Contributor

Set owner to @floitschG.
Added Started label.

@floitschG
Copy link
Contributor

@floitschG
Copy link
Contributor

Removed Oldschool-Milestone-1.6 label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Mar 3, 2018
@matanlurey
Copy link
Contributor

Mirrors is no longer supported in Dart2JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

6 participants