@@ -254,23 +254,29 @@ extension _ArrayBuffer {
254
254
internal func _typeCheckSlowPath( _ index: Int ) {
255
255
if _fastPath ( _isNative) {
256
256
let element : AnyObject = cast ( toBufferOf: AnyObject . self) . _native [ index]
257
- precondition (
258
- element is Element ,
259
- """
260
- Down-casted Array element failed to match the target type
261
- Expected \( Element . self) but found \( type ( of: element) )
262
- """
263
- )
257
+ guard element is Element else {
258
+ _assertionFailure (
259
+ " Fatal error " ,
260
+ """
261
+ Down-casted Array element failed to match the target type
262
+ Expected \( Element . self) but found \( type ( of: element) )
263
+ """ ,
264
+ flags: _fatalErrorFlags ( )
265
+ )
266
+ }
264
267
}
265
268
else {
266
269
let element = _nonNative [ index]
267
- precondition (
268
- element is Element ,
269
- """
270
- NSArray element failed to match the Swift Array Element type
271
- Expected \( Element . self) but found \( type ( of: element) )
272
- """
273
- )
270
+ guard element is Element else {
271
+ _assertionFailure (
272
+ " Fatal error " ,
273
+ """
274
+ NSArray element failed to match the Swift Array Element type
275
+ Expected \( Element . self) but found \( type ( of: element) )
276
+ """ ,
277
+ flags: _fatalErrorFlags ( )
278
+ )
279
+ }
274
280
}
275
281
}
276
282
@@ -505,23 +511,29 @@ extension _ArrayBuffer {
505
511
_native. _checkValidSubscript ( i)
506
512
507
513
element = cast ( toBufferOf: AnyObject . self) . _native [ i]
508
- precondition (
509
- element is Element ,
510
- """
511
- Down-casted Array element failed to match the target type
512
- Expected \( Element . self) but found \( type ( of: element) )
513
- """
514
- )
514
+ guard element is Element else {
515
+ _assertionFailure (
516
+ " Fatal error " ,
517
+ """
518
+ Down-casted Array element failed to match the target type
519
+ Expected \( Element . self) but found \( type ( of: element) )
520
+ """ ,
521
+ flags: _fatalErrorFlags ( )
522
+ )
523
+ }
515
524
} else {
516
525
// ObjC arrays do their own subscript checking.
517
526
element = _nonNative [ i]
518
- precondition (
519
- element is Element ,
520
- """
521
- NSArray element failed to match the Swift Array Element type
522
- Expected \( Element . self) but found \( type ( of: element) )
523
- """
524
- )
527
+ guard element is Element else {
528
+ _assertionFailure (
529
+ " Fatal error " ,
530
+ """
531
+ NSArray element failed to match the Swift Array Element type
532
+ Expected \( Element . self) but found \( type ( of: element) )
533
+ """ ,
534
+ flags: _fatalErrorFlags ( )
535
+ )
536
+ }
525
537
}
526
538
return element
527
539
}
0 commit comments