Skip to content

[silgen] Teach SILGen how to handle a corner case where the clang importer is improperly importing a method with a non-null NSError as throwing #59334

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

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jun 8, 2022

This has been crashing a long time and has never been correct. From an API perspective, the clang importer should have not been importing these methods as throwing. Sadly, today, we need to preserve source compatibility, so in this PR I teach SILGen how to handle this case by passing a nullptr to the non-null API. With time (maybe swift 6), we will be able to eliminate this. I filed rdar://94656178 to track that.

rdar://92755102

gottesmm added 3 commits June 8, 2022 16:28
This API just wraps the current type T into an Optional<T> and returns the
Optional<T> type. We use this all the time in the optimizer and I found I needed
it in SILGen as well but at the AST level, hence the addition.

In the next commit, I change the API in SILType that does this to use this
helper instead. I am doing that to make it easier to cherry-pick this with a
subsequent change I am making to fix a bug.
…on imported objc classes that are imported with a non-null NSError.

This for some time has been crashing in IRGen in non-asserts builds and hitting
assertions in asserts builds. I think we were missing test coverage here and
that is why this basic-ish thing has been broken.

Basically at a high level, the actual expected ABI here is that the NSError is
marked non-nullable which is different from the expected ABI.

rdar://92755102
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 8, 2022

@swift-ci test

@gottesmm gottesmm requested a review from jckarter June 8, 2022 23:31
Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Makes sense for now. Thanks Michael!

@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 9, 2022

I need to disable this on Linux/Windows due to objc. Going to let full Mac OS test pass and then fix linux/windows and do a smoke test

@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 9, 2022

@swift-ci smoke test

@gottesmm gottesmm force-pushed the pr-499eee4e1aca5a8f3f38d1aeb7507c6e761eccd7 branch from 1a93026 to 71179c0 Compare June 9, 2022 18:24
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 9, 2022

@swift-ci smoke test

@gottesmm gottesmm merged commit 9857464 into swiftlang:main Jun 9, 2022
@gottesmm gottesmm deleted the pr-499eee4e1aca5a8f3f38d1aeb7507c6e761eccd7 branch June 9, 2022 23:10
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.

2 participants