diff --git a/stdlib/public/core/ArrayShared.swift b/stdlib/public/core/ArrayShared.swift index 88ef432093981..2de4219a38fc0 100644 --- a/stdlib/public/core/ArrayShared.swift +++ b/stdlib/public/core/ArrayShared.swift @@ -41,9 +41,14 @@ func _allocateUninitializedArray(_ builtinCount: Builtin.Word) if count > 0 { // Doing the actual buffer allocation outside of the array.uninitialized // semantics function enables stack propagation of the buffer. + let storageType: _ContiguousArrayStorage.Type + #if !$Embedded + storageType = getContiguousArrayStorageType(for: Element.self) + #else + storageType = _ContiguousArrayStorage.self + #endif let bufferObject = Builtin.allocWithTailElems_1( - getContiguousArrayStorageType(for: Element.self), - builtinCount, Element.self) + storageType, builtinCount, Element.self) let (array, ptr) = Array._adoptStorage(bufferObject, count: count) return (array, ptr._rawValue) diff --git a/stdlib/public/core/ContiguousArrayBuffer.swift b/stdlib/public/core/ContiguousArrayBuffer.swift index 3573bee92dd22..1454c22d128a1 100644 --- a/stdlib/public/core/ContiguousArrayBuffer.swift +++ b/stdlib/public/core/ContiguousArrayBuffer.swift @@ -297,9 +297,14 @@ internal struct _ContiguousArrayBuffer: _ArrayBufferProtocol { self = _ContiguousArrayBuffer() } else { + let storageType: _ContiguousArrayStorage.Type + #if !$Embedded + storageType = getContiguousArrayStorageType(for: Element.self) + #else + storageType = _ContiguousArrayStorage.self + #endif _storage = Builtin.allocWithTailElems_1( - getContiguousArrayStorageType(for: Element.self), - realMinimumCapacity._builtinWordValue, Element.self) + storageType, realMinimumCapacity._builtinWordValue, Element.self) let storageAddr = UnsafeMutableRawPointer(Builtin.bridgeToRawPointer(_storage)) let allocSize: Int?