-
Notifications
You must be signed in to change notification settings - Fork 1.7k
pkg/meta: @visibleForCodegen #29643
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
Comments
Language team: I think it's rather telling that we have several requests for annotations to effectively broaden the visibility control within the language, things such as |
The annotations story seems kinda just broken without mirrors. When its possible to do
and the only non-deprecated way that that can be used in the browser is via codegen, which cannot access that value ( One possible solution is to make private disallowed inside annotations, which is a breaking change and not necessary for those using mirrors. (and has a lot of edge cases... I'd say the real solution is that annotations have been gutted too much, and either should be replaced (not seriously suggesting this) or a static, tree-shakable API for accessing annotation data and/or annotated data should be developed. Wherein you could simply say something like Maybe both of these things should be done at once? Decide what to do about annotations long term, while this privacy change thing is introduced temporarily? |
Thanks for bringing this up. BTW, this is no way a "we must have this annotation", but rather just trying to used established mechanisms (analysis with a common annotation) to get around a problem folks have been reporting. I personally think Dart should invest in actual visibility control, but beyond this thread maybe? /cc @leafpetersen @floitschG @munificent @MichaelRFairhurst: I think we should keep what the point of annotations are outside of this thread, I don't want to expand scope beyond this particular request and today's tooling. |
Yes, I personally think we should consider more fine-grained access control modifiers. Keeping things simple is good, but it's possible to be too simple. My five-minute sketch would be to add:
|
I don't consider dynamic call sites important, so +1 from me.
It wouldn't really be private, right? It would be public except a static error to reference outside of certain libraries, and obviously tools like dartdoc could take advantage of this knowledge to avoid generating public APIs, etc. |
I was thinking it would actually be private. That ensures you don't run into accidental name collisions when, say, inheriting from the class in a non-friend library. But, again, it's only a half-formed sketch. Making it more public-ish might be a better approach. |
Example
Rationale
Without using partial files (
part
/part of
), it's impossible to use private (_
) variables, which forces developers to write pseudo-public code so that it can be accessed by code generation. However, it serves no other use, and might not even be part of a fully tested public API suite.@visibleForCodegen
would mean:foo.dart
andfoo.g.dart
orfoo.template.dart
@generated
annotation on the generated fileAlternatives
Something like
@friendly
, which means "public to the same package". This is ~the same as@visibleForTesting
, except without any requirement for it to be only used in the test/ directory./cc @kevmoo @alorenzen
The text was updated successfully, but these errors were encountered: