From 572a46f47a69b6e4e3c159534d79a926efe81ddd Mon Sep 17 00:00:00 2001 From: Steve Kirbach Date: Mon, 23 Dec 2024 10:05:50 -0800 Subject: [PATCH] fix array input in debug builds --- swiftwinrt/Resources/Support/IInspectable.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/swiftwinrt/Resources/Support/IInspectable.swift b/swiftwinrt/Resources/Support/IInspectable.swift index f3af818b..9adfa6e4 100644 --- a/swiftwinrt/Resources/Support/IInspectable.swift +++ b/swiftwinrt/Resources/Support/IInspectable.swift @@ -77,7 +77,8 @@ public enum __ABI_ { return makeFrom(abi: ref) ?? ref } public static func tryUnwrapFrom(raw pUnk: UnsafeMutableRawPointer?) -> AnyObject? { - tryUnwrapFromBase(raw: pUnk) + guard let pUnk else { return nil } + return tryUnwrapFromBase(raw: pUnk) } internal static func queryInterface(_ pUnk: UnsafeMutablePointer?, _ riid: UnsafePointer?, _ ppvObject: UnsafeMutablePointer?) -> HRESULT { @@ -151,11 +152,9 @@ public enum __IMPL_ { } public static func from(abi: ComPtr?) -> SwiftProjection? { - // This code path is not actually reachable since IBufferByteAccess is not a WinRT interface. - // It is a COM interface which is implemented by any object which implements the IBuffer interface. - // And the IBufferImpl object will correctly have the implementation of this interface, so this isn't needed - assertionFailure("IBufferByteAccessBridge.from not implemented") - return nil + guard let abi else { return nil } + let ref = IInspectable(abi) + return makeFrom(abi: ref) ?? ref } public typealias SwiftProjection = Any