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

Abstract method missing from ClassMirror's instanceMembers #15727

Closed
DartBot opened this issue Dec 19, 2013 · 10 comments
Closed

Abstract method missing from ClassMirror's instanceMembers #15727

DartBot opened this issue Dec 19, 2013 · 10 comments
Labels
area-library library-mirrors type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Dec 19, 2013

This issue was originally filed by natha...@ofiesh.com


What steps will reproduce the problem?

import "dart:mirrors";

abstract class Foo {
  bar();
}
main() {
  ClassMirror cm = reflectClass(Foo);
  print(cm.instanceMembers[const Symbol("bar")]);
}

What is the expected output? What do you see instead?
Expected "MethodMirror on 'bar'"
Instead it prints null

What version of the product are you using? On what operating system?
Dart Editor version 1.1.0.dev_04_00 (DEV)
Dart SDK version 1.1.0-dev.4.0
Windows 7

Please provide any additional information below.

@DartBot
Copy link
Author

DartBot commented Dec 19, 2013

@lrhn
Copy link
Member

lrhn commented Dec 20, 2013

cc @peter-ahe-google.
Added Area-Library, Library-Mirrors, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Mar 31, 2015

This comment was originally written by @stevenroose


Why isn't this fixed yet?

The documentation for instanceMembers is very clear

Returns a map of the methods, getters and setters of an instance of the class.
The intent is to capture those members that constitute the API of an instance.

It should contain abstract methods since they will be part of every instance of the class.

@lrhn
Copy link
Member

lrhn commented Apr 1, 2015

Abstract members are not part of an instance. They are par of the interface of the class, but not part of an actual instance of that class. It may be an actual member of a subclass, buy is only a warning if it isn't. The documentation seems to match the implementation.

@DartBot
Copy link
Author

DartBot commented Apr 1, 2015

This comment was originally written by natha...@ofiesh.com


If that's the case, IMO "instanceMembers" should be scrapped and replaced with "declaredMembers."

In the mirror api, when getting the instance members, abstract methods are not added to "instanceMembers" because isAbstract == true. This is consistent with that definition, however there is no possible way in the API to reflect abstract methods.

It would be far more useful to have all declared members and methods can be checked for isAbstract if needed.

My problem right now is it's impossible to create a proxy of an abstract class with an abstract method.

So if "instanceMembers" is working as intended, should I open a new bug for "No way to reflect abstract methods?"

@rmacnak-google
Copy link
Contributor

All declared members, including abstract ones, are available in "declarations".

@floitschG
Copy link
Contributor

Can we close this bug?

@lrhn
Copy link
Member

lrhn commented May 7, 2015

I read this as requesting a method that returns all the members of the interface.
The "declarations" map only return members declared in this class, not inherited declarations, and "instanceMembers" returns all declared and inherited concrete members, but I can't find any function returning all members of the interface of the class.

You can find them by traversing the super-class/super-interface tree but that is complex - which is probably why the functionality hasn't been implemented, but also why it's very inconvenient for a user to handle it - especially handling the unification of the types if a member is inherited from more than one interface.

@DartBot
Copy link
Author

DartBot commented May 7, 2015

This comment was originally written by natha...@ofiesh.com


As far as I'm concerned, it can be closed. If it's available in declarations then I don't care. I think declarations might not have been around when I filed this bug a year and a half ago, but not really sure--doesn't matter.

@DartBot
Copy link
Author

DartBot commented May 12, 2015

This comment was originally written by @stevenroose


How about a getter "interfaceMembers" that contains all members of the interface of the class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-library library-mirrors type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants