Skip to content
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

[4.2 2018-06-11] [Clang importer] Don't bridge blocks to Swift functions in ObjC generic arguments. #17261

Conversation

DougGregor
Copy link
Member

Explanation: The Clang importer is importing NSArray<some-typedef-of-a-block-type>* as a Swift array of functions that use the Swift calling convention, which is not supported by the dynamic bridging implementation. Such a type should be imported as a Swift array of block-convention functions, e.g., [@convention(block) (...) -> ...].
Scope: Affects projects that import Objective-C APIs that use types of the aforementioned form.
Risk: Low; importing these APIs with the current Swift 4.2 causes a crash in IR generation.
Testing: Compiler regression tests, including new tests
Reviewer: @jrose-apple
SR / Radar: rdar://problem/40879067

…ic args.

While the compiler can bridge C block types to Swift function types,
the Swift runtime cannot. Don't bridge block types to Swift function
types in Objective-C generic arguments, so

  NSArray<some-block-type>

will get imported as

  [@convention(block) (...) -> Whatever]

rather than

  [(...) -> Whatever]

Fixes rdar://problem/40879067 in a fairly narrow way; the Clang
importer's approach to adjusting types based on context needs a
cleanup, but this is the safe, localized fix suitable for 4.2.

(cherry picked from commit d529002)
…llectionElement.

This better describes what we're importing. Also note why we need to
reset to the block representation.

(cherry picked from commit f595ca7)
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please nominate

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.

None yet

1 participant