diff --git a/runtime/src/main/cpp/ObjCExportCollections.mm b/runtime/src/main/cpp/ObjCExportCollections.mm index 0653aae65f2..9ef0514bd5f 100644 --- a/runtime/src/main/cpp/ObjCExportCollections.mm +++ b/runtime/src/main/cpp/ObjCExportCollections.mm @@ -294,7 +294,10 @@ static inline id KSet_getElement(KRef set, id object) { ObjHolder requestHolder, resultHolder; KRef request = Kotlin_ObjCExport_refFromObjC(object, requestHolder.slot()); KRef result = Kotlin_Set_getElement(set, request, resultHolder.slot()); - return refToObjCOrNSNull(result); + + // Note: if result is nullptr, then it can't be a null element of the set, because request != nullptr; + // so map nullptr to nullptr: + return Kotlin_ObjCExport_refToObjC(result); } }