Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Fix Objective-C block to kotlin.Function* dynamic conversion #3499

Merged
merged 1 commit into from
Oct 28, 2019

Conversation

SvyatoslavScherbina
Copy link
Collaborator

after migrating to synthetic function classes.

after migrating to synthetic function classes.
@@ -440,6 +440,9 @@ static OBJ_GETTER(boxedBooleanToKotlinImp, NSNumber* self, SEL cmd) {

// Note: replaced by compiler in appropriate compilation modes.
__attribute__((weak)) convertReferenceFromObjC* Kotlin_ObjCExport_blockToFunctionConverters = nullptr;
__attribute__((weak)) int Kotlin_ObjCExport_blockToFunctionConverters_size = 0;

extern "C" id objc_retainBlock(id self);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why block retention is different from objects?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There stack-allocated blocks, which are not exactly reference-counted. objc_retain on these blocks is no-op.

Stack-allocated blocks can be copied to heap, a copy is reference-counted and thus "escapable". objc_retainBlock on stack-allocated block performs such copying, and the result has RC=1; for heap-allocated blocks it simply increments RC.

@SvyatoslavScherbina SvyatoslavScherbina merged commit aac2de4 into master Oct 28, 2019
@SvyatoslavScherbina SvyatoslavScherbina deleted the fix-objcexport-block-to-function branch October 28, 2019 07:02
SvyatoslavScherbina added a commit that referenced this pull request Oct 28, 2019
after migrating to synthetic function classes.
SvyatoslavScherbina added a commit that referenced this pull request Oct 29, 2019
after migrating to synthetic function classes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants