mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Introduce _invariantCheck_5_1 for 5.1 and later assertions.
Inlinable and non-inlinable code can cause 5.1 code to intermix with 5.0 code on older OSes. Some (weak) invariants for 5.1 should only be checked when the OS's code is 5.1 or later, which is the purpose of _invariantCheck_5_1. Applied to String.Index._isScalarAligned, which is a new bit introduced in 5.1 from one of the reserved bits from 5.0. The bit is set when the index is proven to be scalar aligned, and we want to assert on this liberally in contexts where we expect it to be so. However, older OSes might not set this bit when doing scalar aligning, depending on exactly what got inlined where/when.
This commit is contained in:
@@ -164,7 +164,7 @@ extension String.Index {
|
||||
internal func _invariantCheck() {
|
||||
_internalInvariant(_encodedOffset >= 0)
|
||||
if self._isScalarAligned {
|
||||
_internalInvariant(transcodedOffset == 0)
|
||||
_internalInvariant_5_1(transcodedOffset == 0)
|
||||
}
|
||||
}
|
||||
#endif // INTERNAL_CHECKS_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user