diff --git a/runtime/src/main/cpp/ObjCExportCollections.mm b/runtime/src/main/cpp/ObjCExportCollections.mm index cd265dfa0bd..1b7e03139fc 100644 --- a/runtime/src/main/cpp/ObjCExportCollections.mm +++ b/runtime/src/main/cpp/ObjCExportCollections.mm @@ -366,7 +366,9 @@ static inline id KSet_getElement(KRef set, id object) { -(instancetype)init { if (self = [super init]) { Kotlin_initRuntimeIfNeeded(); - Kotlin_MutableSet_createWithCapacity(8, self->setHolder.slotToInit()); + ObjHolder holder; + KRef set = Kotlin_MutableSet_createWithCapacity(8, holder.slot()); + self->setHolder.init(set); } return self; @@ -375,7 +377,9 @@ static inline id KSet_getElement(KRef set, id object) { - (instancetype)initWithCapacity:(NSUInteger)numItems { if (self = [super init]) { Kotlin_initRuntimeIfNeeded(); - Kotlin_MutableSet_createWithCapacity(objCCapacityToKotlin(numItems), self->setHolder.slotToInit()); + ObjHolder holder; + KRef set = Kotlin_MutableSet_createWithCapacity(objCCapacityToKotlin(numItems), holder.slot()); + self->setHolder.init(set); } return self; @@ -511,7 +515,9 @@ static inline id KMap_get(KRef map, id aKey) { -(instancetype)init { if (self = [super init]) { Kotlin_initRuntimeIfNeeded(); - Kotlin_MutableMap_createWithCapacity(8, self->mapHolder.slotToInit()); + ObjHolder holder; + KRef map = Kotlin_MutableMap_createWithCapacity(8, holder.slot()); + self->mapHolder.init(map); } return self; } @@ -525,7 +531,9 @@ static inline id KMap_get(KRef map, id aKey) { - (instancetype)initWithCapacity:(NSUInteger)numItems { if (self = [super init]) { Kotlin_initRuntimeIfNeeded(); - Kotlin_MutableMap_createWithCapacity(objCCapacityToKotlin(numItems), self->mapHolder.slotToInit()); + ObjHolder holder; + KRef map = Kotlin_MutableMap_createWithCapacity(objCCapacityToKotlin(numItems), holder.slot()); + self->mapHolder.init(map); } return self; }