Skip to content

Support generic @compatibility_alias in PrintAsObjC #33573

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

beccadax
Copy link
Contributor

When Objective-C's @compatibility_alias feature is used with a class using lightweight generics, this ends up importing as a generic Swift typealias. PrintAsObjC previously didn’t handle declarations involving these types correctly; it would fail an assertion in asserts compilers, and potentially print an incorrect compatibility header in non-asserts compilers.

This PR makes it so that PrintAsObjC can now correctly print generic compatibility aliases imported from Objective-C modules. It is, of course, still not possible to declare a generic typealias in Swift that will be printed into the Objective-C header.

This PR also adds a ClangNode::dump() method for use in the debugger and adds doc comments clarifying what TypeAliasDecl::{is,markAs}CompatibilityAlias() are for (and that they have nothing to do with @compatibility_alias).

Fixes rdar://67256866.

When @compatibility_alias is used with an ObjC generic class, this ends up importing as a generic typealias. PrintAsObjC previously didn’t handle declarations involving these types correctly; it would fail an assertion in asserts compilers, and potentially print an incorrect compatibility header in non-asserts compilers.

This PR makes it so that PrintAsObjC can now correctly use generic typealiases imported from Objective-C modules. It is, of course, still not possible to declare a generic typealias in Swift that will be printed into the Objective-C header.

Fixes rdar://67256866.
@beccadax beccadax requested a review from slavapestov August 20, 2020 23:30
@beccadax
Copy link
Contributor Author

@swift-ci please test

@slavapestov
Copy link
Contributor

Looks great. Thanks for untangling this!

@beccadax beccadax merged commit 828ab6d into swiftlang:master Aug 21, 2020
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.

3 participants