You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reflection API seems to provide no easy way to check for a symbol being private[this]. The only way I could find to do it is to explicitly check for hasFlag(LOCAL). It seems too important and fundamental to require direct access to flags like this.
Meanwhile, there is a method called isLocal that sounds like it is supposed to check for private[this]. The API doc for this method talks about access being limited to the enclosing object. That's not what the method actually returns, however. What the method returns is whether the symbol is defined within a term, as opposed to within a class.
It looks like the API method has had an accidental collision with a method that already exists in the Scala compiler. In my opinion, the definition in the compiler is a better match for the name "isLocal". Thus, add a new method to check for private[this], perhaps named isPrivateThis.
The text was updated successfully, but these errors were encountered:
@paulp said:
There is such a method (only on the compiler side) called isPrivateLocal; to be consistent with the specification, the name should maybe be isObjectPrivate. Although I tend to wish for things to be called the same thing they're called, so isPrivateThis is more appealing if the naming is done consistently.
The reflection API seems to provide no easy way to check for a symbol being private[this]. The only way I could find to do it is to explicitly check for hasFlag(LOCAL). It seems too important and fundamental to require direct access to flags like this.
Meanwhile, there is a method called isLocal that sounds like it is supposed to check for private[this]. The API doc for this method talks about access being limited to the enclosing object. That's not what the method actually returns, however. What the method returns is whether the symbol is defined within a term, as opposed to within a class.
It looks like the API method has had an accidental collision with a method that already exists in the Scala compiler. In my opinion, the definition in the compiler is a better match for the name "isLocal". Thus, add a new method to check for private[this], perhaps named isPrivateThis.
The text was updated successfully, but these errors were encountered: