@@ -254,23 +254,29 @@ extension _ArrayBuffer {
254254 internal func _typeCheckSlowPath( _ index: Int ) {
255255 if _fastPath ( _isNative) {
256256 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+ }
264267 }
265268 else {
266269 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+ }
274280 }
275281 }
276282
@@ -505,23 +511,29 @@ extension _ArrayBuffer {
505511 _native. _checkValidSubscript ( i)
506512
507513 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+ }
515524 } else {
516525 // ObjC arrays do their own subscript checking.
517526 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+ }
525537 }
526538 return element
527539 }
0 commit comments