Skip to content

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Oct 31, 2016

  • Explanation: The generated Objective-C header did not properly make sure the definition of an imported Objective-C generic type was included before its use. Current support for a forward @class declaration isn't good enough here because that doesn't include arguments, and since any such types will be coming from Objective-C anyway (because Swift can't define Objective-C-compatible generic types) it's safe to just import the original framework. There is a workaround here, though, which is to import the necessary framework before importing the generated header in any .m files.

  • Scope: Affects generated headers for code using Objective-C generic types other than NSArray, NSSet, and NSDictionary. (In the problem case, these headers weren't valid Objective-C.)

  • Issue: rdar://problem/28738008

  • Reviewed by: @DougGregor

  • Risk: This is mostly using an existing code path, just applying it to more types. This may reveal bugs where there weren't any before. Other than that, though, this should be pretty safe—the cases it's designed to affect wouldn't have compiled before.

  • Testing: Added a compiler regression test, verified that the original example now behaves correctly.

…wiftlang#5518)

I'm not sure why this didn't occur to me in 8282160: of course if you
see a generic type with arguments, you need to see the @interface for
that type in order to supply the arguments. Maybe I was thinking the
generated interface would automatically import anything the module
itself imports, but that hasn't ever been true.

rdar://problem/28738008
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@ematejska ematejska merged commit a29f9a1 into swiftlang:swift-3.0-branch Nov 1, 2016
@jrose-apple jrose-apple deleted the swift-3.0-PrintAsObjC-generics-again branch November 1, 2016 00:27
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