Skip to content

Weakly import declarations with conditional availability #22729

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 3 commits into from
Feb 20, 2019

Conversation

slavapestov
Copy link
Contributor

Fixes rdar://46674512.

For now, it's not used, but we do try to pass the right value down from
our various call sites.

Progress on <rdar://problem/46674512>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit b4dafae into swiftlang:master Feb 20, 2019
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

I don't think this is the correct approach. You need to weak-reference things if your deployment target isn't new enough; it doesn't matter what the use site's AvailabilityContext is. Therefore it doesn't need to be an extra parameter.

@slavapestov
Copy link
Contributor Author

It’s not passing in the use site’s local AvailabilityContext. It’s always passing in the global one from the ASTContext. I guess I could get rid of the extra parameter but I’m not a huge fan of all the global state in the ASTContext in general.

@jrose-apple
Copy link
Contributor

I agree about the global state but in this case I think it's the lesser of two evils. Having the parameter encourages people to pass the wrong thing, especially if/when we start using AvailabilityContext in SIL.

@slavapestov
Copy link
Contributor Author

@jrose-apple OK then, I'll clean that up. Other than changing it to always use the global AvailabilityContext do you think this is the right approach?

@jrose-apple
Copy link
Contributor

Yeah, I think this is reasonable. If we wanted to handle backwards-deployment-without-availability or directly testing symbols for presence/absence it'd be more difficult, but for what we need right now this makes sense. (And the explicit @_weakLinked is close to handling the rest.)

@jrose-apple
Copy link
Contributor

Conformances might be tricky, though, since those aren't Decls.

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