-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-7082 |
Radar | None |
Original Reporter | @jckarter |
Type | Bug |
Additional Detail from JIRA
Votes | 2 |
Component/s | Compiler |
Labels | Bug, LanguageFeatureRequest |
Assignee | None |
Priority | Medium |
md5: 400c319da94f2aeb9aecf260173023c7
Issue Description:
We won't let you override a property from a base class with a stored property:
class Base {
var property: Int { fatalError("abstract") }
}
class Derived: Base {
override var property: 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.