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

getter <-> setter Symbol translation in mirrors is cumbersome / inefficent #10975

Closed
DartBot opened this issue May 30, 2013 · 6 comments
Closed
Assignees
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 P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented May 30, 2013

This issue was originally filed by ross.dart....@gmail.com


As I brought up on the mailing list here:

https://groups.google.com/a/dartlang.org/forum/?fromgroups=#!topic/eng/kFBIcD3KBAY

I also have some code in the `reflectFields' method of the following file that demonstrates looking for a setter in a ClassMirror based on having a getter's Symbol:

https://github.com/rmsmith/fields/blob/master/lib/field.dart

@justinfagnani
Copy link
Contributor

I think we'll want some kind of isSetter(Symbol s) / isGetter(Symbol s) API as well.


cc @gbracha.
Added Library-Mirrors, Triaged labels.

@justinfagnani
Copy link
Contributor

Added Area-Library label.

@peter-ahe-google
Copy link
Contributor

I think we should add two getters to Symbol:

/// If this symbol is a setter name, return it. Otherwise, return the symbol corresponding to adding '=' to this symbol.
/// TBD: Throw an error if this symbol corresponds to an empty string.
Symbol get asSetterSymbol();
/// If this symbol is not a setter name, return it. Otherwise, return the symbol corresponding to removing a trailing '='.
Symbol get asGetterSymbol();


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

@gbracha
Copy link
Contributor

gbracha commented May 30, 2013

sgtm

@jmesserly
Copy link

Issue #13587 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Oct 2, 2013

This comment was originally written by @seaneagan


Symbols can represent not only getter/setter names, but also operator, class, and library names. And it can also be ambiguous as to which one of those a particular Symbol represents, even more so after minification. How would these work:

  1. #+.asSetterSymbol()
  2. (#my.lib.name).asGetterSymbol()
  3. (#MyClass).asSetterSymbol()
  4. and 2. could potentially throw, but I'm not sure if it is always possible to tell if a minified Symbol represented an operator / library name. Otherwise (and with 3. ), it would have to return a bogus Symbol, which will lead to incorrect behavior elsewhere in the program. Similarly isGetter etc. could lead to false positives:

(#MyClass).isGetter
(#my_lib).isGetter

Adding PropertyMirror and "properties" getters, and using those to lookup properties via the plain identifier Symbol, and retrieving the getter/setter from that seems like a good solution to me.

@DartBot DartBot added Type-Defect library-mirrors area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Oct 2, 2013
@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 accepted labels Feb 29, 2016
@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 P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants