[xtro] Fix checking availability on categories. - #2682
Merged
spouliot merged 1 commit intoSep 13, 2017
Conversation
When checking for category availability, check if both the current declaration is a category, and if the current's declaration container is a category. Otherwise this scenario fails: * Category method is available. * Category does not have availability attributes. * Main class is unavailable. with this typical code sequence: ```csharp // don't process methods (or types) that are unavailable for the current platform if (!decl.IsAvailable () || !(decl.DeclContext as Decl).IsAvailable ()) return; ``` In which case we'd: * First check the method (`decl`): * It's available, so no further checks is done on the method. * Then we'd check the method's container (`decl.DeclContext`): * The container (the category) does not have availability attributes. * Then we'd check if the container's container is a category (it isn't, it's the namespace). and as such determine that the method is available. With this change, the second step will become: * Then we'd check the method's container (`decl.DeclContext`): * The container (the category) does not have availability attributes. * Then we'd check if the container is a category (it is), and if its main class is available (it isn't). and as such determine that the method is unavailable. * Check for attributes on the method's container (no attributes, so we continue). * Check if the method's Unclassified diff: https://gist.github.com/rolfbjarne/8fa80962596978a426eadf9b7ba39dc1
Contributor
|
merging right now as this is not executed on bots |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When checking for category availability, check if both the current declaration
is a category, and if the current's declaration container is a category.
Otherwise this scenario fails:
with this typical code sequence:
In which case we'd:
First check the method (
decl):Then we'd check the method's container (
decl.DeclContext):and as such determine that the method is available.
With this change, the second step will become:
decl.DeclContext):and as such determine that the method is unavailable.
Unclassified diff: https://gist.github.com/rolfbjarne/8fa80962596978a426eadf9b7ba39dc1