[stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)

* Replace "sanityCheck" with "internalInvariant"
This commit is contained in:
Ben Cohen
2018-11-15 20:50:22 -08:00
committed by GitHub
parent add6f126ad
commit 1673c12d78
74 changed files with 607 additions and 603 deletions

View File

@@ -615,7 +615,7 @@ extension UTF8.CodeUnit : _StringElement {
@inlinable
public // @testable
static func _toUTF16CodeUnit(_ x: UTF8.CodeUnit) -> UTF16.CodeUnit {
_sanityCheck(x <= 0x7f, "should only be doing this with ASCII")
_internalInvariant(x <= 0x7f, "should only be doing this with ASCII")
return UTF16.CodeUnit(truncatingIfNeeded: x)
}
@inlinable
@@ -623,7 +623,7 @@ extension UTF8.CodeUnit : _StringElement {
static func _fromUTF16CodeUnit(
_ utf16: UTF16.CodeUnit
) -> UTF8.CodeUnit {
_sanityCheck(utf16 <= 0x7f, "should only be doing this with ASCII")
_internalInvariant(utf16 <= 0x7f, "should only be doing this with ASCII")
return UTF8.CodeUnit(truncatingIfNeeded: utf16)
}
}
@@ -871,9 +871,9 @@ extension Unicode.Scalar {
/// precondition checks for code point validity.
@inlinable
internal init(_unchecked value: UInt32) {
_sanityCheck(value < 0xD800 || value > 0xDFFF,
_internalInvariant(value < 0xD800 || value > 0xDFFF,
"high- and low-surrogate code points are not valid Unicode scalar values")
_sanityCheck(value <= 0x10FFFF, "value is outside of Unicode codespace")
_internalInvariant(value <= 0x10FFFF, "value is outside of Unicode codespace")
self._value = value
}