mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
stdlib: don't use assert() in stdlib implementation
Swift SVN r18653
This commit is contained in:
@@ -210,7 +210,7 @@ extension ArrayBuffer {
|
||||
// Could be sped up, e.g. by using
|
||||
// enumerateObjectsAtIndexes:options:usingBlock:
|
||||
for i in subRange {
|
||||
assert(ns.objectAtIndex(i) is T,
|
||||
_precondition(ns.objectAtIndex(i) is T,
|
||||
"NSArray element failed to match the Swift Array Element type")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,9 +375,11 @@ func ${op} (lhs: ${Self}, rhs: ${Self}) -> Bool {
|
||||
@transparent
|
||||
func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
|
||||
% if signed:
|
||||
assert(U${Self}(rhs) < U${Self}(sizeofValue(rhs) * 8))
|
||||
_precondition(U${Self}(rhs) < U${Self}(sizeofValue(rhs) * 8),
|
||||
"shift amount is larger than type size in bits")
|
||||
% else:
|
||||
assert(rhs < ${Self}(sizeofValue(rhs) * 8))
|
||||
_precondition(rhs < ${Self}(sizeofValue(rhs) * 8),
|
||||
"shift amount is larger than type size in bits")
|
||||
% end
|
||||
return ${Self}(Builtin.${name}_${BuiltinName}(lhs.value, rhs.value))
|
||||
}
|
||||
|
||||
@@ -483,8 +483,10 @@ extension ${Self} {
|
||||
% for srcBits in allFloatBits:
|
||||
% That = floatName(srcBits)
|
||||
init(_ v: ${That}) {
|
||||
assert(v >= ${That}(${Self}.min))
|
||||
assert(v <= ${That}(${Self}.max))
|
||||
_precondition(v >= ${That}(${Self}.min),
|
||||
"floating point value can not be converted to ${Self} because it is greater than ${Self}.min")
|
||||
_precondition(v <= ${That}(${Self}.max),
|
||||
"floating point value can not be converted to ${Self} because it is less than ${Self}.min")
|
||||
value = Builtin.fpto${sign}i_FPIEEE${srcBits}_${BuiltinName}(v.value)
|
||||
}
|
||||
% end
|
||||
|
||||
@@ -91,7 +91,7 @@ case "32": let x = Int64(pf)
|
||||
default: break
|
||||
}
|
||||
|
||||
// CHECK: assertion failed: file {{.*}}/FloatingPoint.swift, line {{[0-9]*}}
|
||||
// CHECK: fatal error: floating point value can not be converted
|
||||
// CHECK-NEXT: CRASHED: SIG{{ILL|TRAP}}
|
||||
println("BUSTED: should have crashed already")
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user