-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Need API for creating private symbols w/r/t a given library #13355
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
This is somewhat iffy, but we do like to use constant symbols, so we could say: Symbol LibraryMirror.createSymbol(Symbol) If the given symbol doesn't start with an underscore, it is added. So this would work: myLibraryMirror.createSymbol(#_privateName); |
Our current thinking is LibraryMirror.createSymbol() should take a string and emit the same warning(hint?) as new Symbol. |
Added Area-Library label. |
In order for my suggestion to make sense, the method should be renamed to createPrivateSymbol. I discussed this method with Ryan, and we both agreed it would be nicer if you could pass in strings. However, then dart2js needs to warn (as it does for new Symbol). However, dart2js cannot reliably warn about instance methods (due to optional types). So I would prefer a static method on MirrorSystem. |
wrt comment #1: createPrivateSymbol(#_privateName) and createPrivateSymbol(#privateName) should not return the same symbol. It is perfectly legal to have private variables "___foo", and it should be clear how to construct a symbol for it. wrt comment #4: I currently don't see the big advantage of using strings (after all it's just a new Symbol(string) away), but even with symbols we would need to track the symbols or always assume that the private version of a symbol exists too. Personally I prefer instance methods, but I can understand if that won't work here. |
Marked this as blocking #13559. |
Marked this as blocking #13881. |
MirrorSystem.getSymbol added in r28551 Added Fixed label. |
is there a dart2js bug for this? (when only one side is fixed, we can't use it yet from library code, so I need a new bug # to mark things blocked against.) |
This comment was originally written by [email protected] MirrorSystem.getSymbol("foo") will always throw an ArgumentError, I assume line 49 should be: if ((library != null && library is! LibraryMirror) || 48 /* patch */ static Symbol getSymbol(String name, [LibraryMirror library]) { |
We shouldn't check the type, that's what checked mode is for. |
Greg, yes. Peter, I still want to check the type before handing things off to a primitive where it would hit an assertion error and crash rather than throw a runtime error. (Say you passed a ClassMirror instead of a LibraryMirror, which also has a reflectee which is a MirrorReference, but which has the wrong VM object inside.) |
I can implement LibraryMirror myself. You need to find a different way to protect native code. |
Symbol LibraryMirror.createSymbol(String)?
The text was updated successfully, but these errors were encountered: