Skip to content

Do not import objc_direct constructors #40234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged

Do not import objc_direct constructors #40234

merged 1 commit into from
Dec 21, 2021

Conversation

ellishg
Copy link
Contributor

@ellishg ellishg commented Nov 17, 2021

Unlike normal Objective-C functions, Swift does not directly call
Objective-C constructors because it creates a thunk to allocate the
object and call then constructor dynamically. This can be fixed, but for
now emit a compile-time error rather than a runtime error.

@ellishg
Copy link
Contributor Author

ellishg commented Nov 19, 2021

@rjmccall @CodaFi @slavapestov Could someone take a look? We ran into the unhandled case when Swift tries to call an ObjC constuctor marked as objc_direct.

@gottesmm gottesmm requested a review from beccadax December 7, 2021 22:06
@gottesmm
Copy link
Contributor

gottesmm commented Dec 7, 2021

@beccadax not sure if you are the correct reviewer, but I thought you would know better than me.

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

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

I have some small requests, but this is basically sound.

Incidentally, I recently extracted some nearby code from importAttributes() into a new importSwiftAttrAttributes() method. Your change should still be in importAttributes(), not the new method.

Unlike normal Objective-C functions, Swift does not directly call
Objective-C constructors because it creates a thunk to allocate the
object and call then constructor dynamically. This can be fixed, but for
now emit a compile-time error rather than a runtime error.
@ellishg
Copy link
Contributor Author

ellishg commented Dec 16, 2021

ping @beccadax could you take another quick look? I believe I've made the changes you suggested

@lanza
Copy link
Contributor

lanza commented Dec 20, 2021

@swift-ci please test

@lanza lanza self-requested a review December 20, 2021 19:40
@lanza
Copy link
Contributor

lanza commented Dec 20, 2021

This LGTM if nobody else has any concerns!

@lanza lanza merged commit dc0bd52 into swiftlang:main Dec 21, 2021
@CodaFi
Copy link
Contributor

CodaFi commented Dec 22, 2021

@ellishg I've sketched lifting this restriction, and also moving [direct] into SIL itself, here https://github.com/CodaFi/swift/tree/airline-railway

@manman-ren
Copy link

@ellishg I've sketched lifting this restriction, and also moving [direct] into SIL itself, here https://github.com/CodaFi/swift/tree/airline-railway

@CodaFi Hey will you have time to upload the patch for review? Or it still needs some more work?
This is the last piece left to fully support direct ObjC methods from Swift.

Thanks!
Manman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants