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
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
Set owner to @peter-ahe-google. |
Marked this as blocking #6490. |
Added this to the M7 milestone. |
Issue #13733 has been merged into this issue. |
Removed this from the 1.6 milestone. |
Set owner to @floitschG. |
Removed Oldschool-Milestone-1.6 label. |
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
added
the
closed-obsolete
Closed as the reported issue is no longer relevant
label
Mar 3, 2018
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
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)
The text was updated successfully, but these errors were encountered: