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
Standalone code, or other way to reproduce the problem
For the moment, private parameters and methods can use variant parameters in any position. private is also the only access modifier that allows these otherwise illegal definitions, but as pointed out in #7216 , it isn't actually typesafe. Instead, Scala's "object-private" and "object-protected" access modifiers would make such declarations sound. Object-private is purely stricter than the current scheme, so the advantage is solely for type safety.
However, object-protected brings something new and powerful, especially with properties. I've found it cumbersome, and sometimes impossible, to cleanly extend classes with variant parameters in properties, because there is no way to interact with them in the subclass in the opposite direction of their variance. For example, #7573 would actually ideally be solved by making ImmutableWrapper::collection object-protected.
The same is true of generic methods. object protected as a method access modifier would allow subclasses to override parent definitions of reused internal methods to refine the functionality.
An admittedly artificial but still demonstrative culminating example:
HHVM Version
Standalone code, or other way to reproduce the problem
For the moment, private parameters and methods can use variant parameters in any position.
private
is also the only access modifier that allows these otherwise illegal definitions, but as pointed out in #7216 , it isn't actually typesafe. Instead, Scala's "object-private" and "object-protected" access modifiers would make such declarations sound. Object-private is purely stricter than the current scheme, so the advantage is solely for type safety.However, object-protected brings something new and powerful, especially with properties. I've found it cumbersome, and sometimes impossible, to cleanly extend classes with variant parameters in properties, because there is no way to interact with them in the subclass in the opposite direction of their variance. For example, #7573 would actually ideally be solved by making
ImmutableWrapper::collection
object-protected.The same is true of generic methods.
object protected
as a method access modifier would allow subclasses to override parent definitions of reused internal methods to refine the functionality.An admittedly artificial but still demonstrative culminating example:
andrewjkennedy mentioned that this might come to Hack eventually. Any guesses as to when if ever?
The text was updated successfully, but these errors were encountered: