mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce safety checkin for ConcurrentValue conformance.
Introduce checking of ConcurrentValue conformances: - For structs, check that each stored property conforms to ConcurrentValue - For enums, check that each associated value conforms to ConcurrentValue - For classes, check that each stored property is immutable and conforms to ConcurrentValue Because all of the stored properties / associated values need to be visible for this check to work, limit ConcurrentValue conformances to be in the same source file as the type definition. This checking can be disabled by conforming to a new marker protocol, UnsafeConcurrentValue, that refines ConcurrentValue. UnsafeConcurrentValue otherwise his no specific meaning. This allows both "I know what I'm doing" for types that manage concurrent access themselves as well as enabling retroactive conformance, both of which are fundamentally unsafe but also quite necessary. The bulk of this change ended up being to the standard library, because all conformances of standard library types to the ConcurrentValue protocol needed to be sunk down into the standard library so they would benefit from the checking above. There were numerous little mistakes in the initial pass through the stsandard library types that have now been corrected.
This commit is contained in:
@@ -61,7 +61,7 @@ extension String {
|
||||
/// }
|
||||
/// // Prints "My favorite emoji is "
|
||||
@frozen
|
||||
public struct UnicodeScalarView {
|
||||
public struct UnicodeScalarView: ConcurrentValue {
|
||||
@usableFromInline
|
||||
internal var _guts: _StringGuts
|
||||
|
||||
@@ -169,7 +169,7 @@ extension String.UnicodeScalarView: BidirectionalCollection {
|
||||
|
||||
extension String.UnicodeScalarView {
|
||||
@frozen
|
||||
public struct Iterator: IteratorProtocol {
|
||||
public struct Iterator: IteratorProtocol, ConcurrentValue {
|
||||
@usableFromInline
|
||||
internal var _guts: _StringGuts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user