Skip to content

Commit 6d03fe0

Browse files
committed
Add an assert to ArrayBuffer.getElementSlowPath.
The implementation is making a strong assumption about the array element type (single-reference layout), but it is extremely non-obvious that this helper is only called for those element types. Swift SVN r30183
1 parent 59f912a commit 6d03fe0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/public/core/ArrayBuffer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ extension _ArrayBuffer {
372372

373373
@inline(never)
374374
func _getElementSlowPath(i: Int) -> AnyObject {
375+
assert(_isClassOrObjCExistential(Element.self), "Only single reference elements can be indexed here.")
375376
let element: AnyObject
376377
if _isNative {
377378
// _isValidSubscript does no subscript checking for the slow path.

0 commit comments

Comments
 (0)