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
jckarter opened this issue
Feb 26, 2018
· 2 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
We won't let you override a property from a base class with a stored property:
classBase {
varproperty: Int { fatalError("abstract") }
}
classDerived: Base {
overridevarproperty: Int// an error
}
This prohibition came from fear that people might override a property with new storage by accidentally redeclaring the property in their derived class. This decision was made in ancient times before the override keyword was even added and was never revisited. We should reconsider it now that overrides are always explicit.
One remaining potential ambiguity is in the behavior of overrides with observers. Currently, an override with observers always adds the observers on top of the super implementation. If we allow stored properties to be overrides, it may be ambiguous whether an override with didSet/willSet is intended to be a new stored property with and observers or an extension of the base class property with observers.
The text was updated successfully, but these errors were encountered:
Along the same lines (I think), it remains surprising (I think) that an initialized `let` property cannot be overridden by another initialized `let` property. It's hard to see what harm that could do.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
Additional Detail from JIRA
md5: 400c319da94f2aeb9aecf260173023c7
Issue Description:
We won't let you override a property from a base class with a stored property:
This prohibition came from fear that people might override a property with new storage by accidentally redeclaring the property in their derived class. This decision was made in ancient times before the
override
keyword was even added and was never revisited. We should reconsider it now that overrides are always explicit.One remaining potential ambiguity is in the behavior of overrides with observers. Currently, an override with observers always adds the observers on top of the super implementation. If we allow stored properties to be overrides, it may be ambiguous whether an override with didSet/willSet is intended to be a new stored property with and observers or an extension of the base class property with observers.
The text was updated successfully, but these errors were encountered: