-
Notifications
You must be signed in to change notification settings - Fork 56
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
Private members no way to implement, or is there #33
Comments
The problem is that the transformer cannot modify files in other packages (barback limitation dart-archive/barback#39). Can you explain more about your use-case. Maybe there is a better solution (if the fields should be manipulated from the outside they should probably not be private in the first place). |
This is currently blocked on dart-archive/barback#39. |
Just making an intermediate assumption explicit: Jake, it sounds like you have a package P, that package contains some private declarations, say, including In that case you'd need the cross-package transformation feature that Sigurd mentioned (and in that case I'm also tempted to ask why such a "semantically public" feature would need to be technically private). However, if you want to use the reflectable transformer inside your package P, and the issue is that some libraries in P need to access private declarations in other libraries in P, then it would be sufficient if reflectable could access private features inside the same package. That would not be impossible, but it would require a non-trivial amount of refactoring (so with the current version of reflectable it is impossible, and if we decide that we want to add this feature then it still needs to be done). |
You could certainly write some accessor proxies in the library that contains the private declarations (e.g., if |
Is there any progress to expect on this issue? |
Dart privacy is a hard protection (that is, there is no way to circumvent it in a Dart program), and reflectable relies on generated code (so execution can only do things that a Dart program can do), so the lack of support for access to private declarations is a hard limitation. So, unfortunately, there is no progress. |
Ok, so if understand correctly, dart would need a capability like:
Would it make sense to open an issue on dart/language? The above example is obviously very dangerous, but maybe we could collect ideas on how to tackle this? Is there any cause why this isn't closed? |
There have been various discussions about privacy in the language repo. I don't think there is one specifically about allowing privacy to be violated in regular Dart code. This issue has been kept open for a couple of reasons. One is that we used to consider different code generation schemes. In particular, if reflectable were to generate a Another possibility is that developers could provide hooks (e.g., However, there are no concrete plans to add such hooks. So I'll close the issue. It will still serve as a location where we can get information about why this restriction exists. |
I am looking at doing this in a library I maintain. The solution I was thinking of using was adding accessor proxys to the library files that contain the private members there for making them usable. Would this be appropriate for this package.
Obviously this would be done using a transformer.
The text was updated successfully, but these errors were encountered: