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
When I inherit a protocol adding mutating keyword to the property with the same name from the parent protocol, I can't create a concrete type even there's no compile error for the protocols.
Check out this code:
protocolFooProtocol {
varvalue: Int { get }
}
protocolMutatingFooProtocol: FooProtocol {
varvalue: Int { mutatingget }
}
// no compile error so far.structBar: MutatingFooProtocol {
privatevarstorage: Intvarvalue: Int {
mutatingget {
self.storage += 1returnself.storage
}
}
}
This produces compile error that Bar is not conforming to protocol FooProtocol. but adding non mutating var value: Int does not solve the problem. It creates another compile error `Invalid redeclaration of value.
I think inheriting same property name with adding mutating attribute should not be allowed from the first place.
The text was updated successfully, but these errors were encountered:
Environment
Xcode 10, Swift 4.2
Additional Detail from JIRA
md5: 6e3fa72d7ffc426051b8986f44b6f4d3
Issue Description:
When I inherit a protocol adding mutating keyword to the property with the same name from the parent protocol, I can't create a concrete type even there's no compile error for the protocols.
Check out this code:
This produces compile error that Bar is not conforming to protocol FooProtocol. but adding non mutating var value: Int does not solve the problem. It creates another compile error `Invalid redeclaration of value.
I think inheriting same property name with adding mutating attribute should not be allowed from the first place.
The text was updated successfully, but these errors were encountered: