Warn about unnecessary availability independently from the deployment target #37350
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.
This change separates emission of the "unnecessary availability" diagnostics:
from the deployment target of the current compilation. Instead, these diagnostics will only be emitted if the enclosing scope guard is explicitly specified by the user with an
#availability
attribute.This fixes cases like the following:
Compiling this with
-target x86_64-apple-macos11.2
results in:Even though in source-code the enclosing scope (
Foo
) of this guard does not ensure it will always be true.This happens because availability range is propagated by intersecting ranges top-down from the root
TypeRefinementContext
, which is defined by the deployment target, causing the availability range on classFoo
to become11.2
.Users may be sharing the same piece of source-code across different projects with their own respective deployment targets which makes such target-dependent warnings confusing at some times, and not-useful at others.
We should rather have the warning simply reflect what is in the source.
Resolves rdar://77607488