Skip to content

SR-2709: @available(swift, ...) #4985

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 13 commits into from
Oct 12, 2016

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Sep 23, 2016

This PR addresses SR-2709, and corresponds to the proposal currently under review in
https://lists.swift.org/pipermail/swift-evolution-announce/2016-September/000286.html

It's a relatively minor extension to the @available(...) system to permit availability testing
by swift language version. A companion to the previous PR #4826 that enables command-line
backwards compatibility adjustment of the compiler's effective language version.

I'm posting here for implementation review; it should not be merged until the evolution proposal
has been reviewed and approved by the community. I'll amend here to track any changes that
come up during that discussion.

Resolves SR-2709.

@CodaFi CodaFi added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Sep 25, 2016
/// The entity might be unavailable, because it was introduced after
/// the minimum version.
/// The entity might be unavailable at runtime, because it was introduced
/// after the requested minimum platform version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You say "platform or language" version above but "platform" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct; potential-availability only applies to platform, not language.

@@ -618,21 +619,24 @@ class AvailableAttr : public DeclAttribute {
/// Indicates when the symbol was obsoleted.
const Optional<clang::VersionTuple> Obsoleted;

/// Indicates if the declaration has unconditional availability.
const UnconditionalAvailabilityKind Unconditional;
/// Indicates if the declaration has plafrorm-agnostic availability.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: plafrorm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@graydon graydon force-pushed the SR-2709-available-swift-version branch 2 times, most recently from dd3489d to 87bce60 Compare September 28, 2016 01:55
@graydon
Copy link
Contributor Author

graydon commented Sep 28, 2016

@swift-ci Please smoke test

"'swift' version-availability must be specified alone", ())

ERROR(pound_available_swift_not_allowed, none,
"Swift language version checks not allowed in #available(...)", ())
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add tests for these diagnostics!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -3104,6 +3104,10 @@ ERROR(availability_decl_unavailable_in_swift_msg, none,
NOTE(availability_marked_unavailable, none,
"%0 has been explicitly marked unavailable here", (DeclName))

NOTE(availability_introduced_in_swift, none,
"%0 was introduced in swift %1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: "Swift" should be capitalized here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

// FIXME: Use of the platformString here is non-awesome for application
// extensions.
diagnose(D, diag::availability_obsoleted, Name,
Attr->prettyPlatformString(),
(Attr->isLanguageVersionSpecific() ?
"swift" : Attr->prettyPlatformString()),
Copy link
Contributor

Choose a reason for hiding this comment

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

…and here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@graydon graydon force-pushed the SR-2709-available-swift-version branch from 87bce60 to 220fc24 Compare October 7, 2016 20:16
@graydon graydon added swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process and removed swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review labels Oct 7, 2016
@graydon
Copy link
Contributor Author

graydon commented Oct 7, 2016

@swift-ci please test and merge

@graydon
Copy link
Contributor Author

graydon commented Oct 11, 2016

@swift-ci please smoke test and merge

@graydon
Copy link
Contributor Author

graydon commented Oct 12, 2016

@swift-ci please test and merge

@graydon
Copy link
Contributor Author

graydon commented Oct 12, 2016

@swift-ci please smoke test

@graydon
Copy link
Contributor Author

graydon commented Oct 12, 2016

@swift-ci please test and merge

@graydon
Copy link
Contributor Author

graydon commented Oct 12, 2016

@swift-ci please clean test and merge

@graydon graydon force-pushed the SR-2709-available-swift-version branch from dc7a5ca to 3ca7555 Compare October 12, 2016 18:21
@graydon
Copy link
Contributor Author

graydon commented Oct 12, 2016

@swift-ci Please smoke test and merge

@graydon graydon merged commit 28b13a1 into swiftlang:master Oct 12, 2016
@jtbandes
Copy link
Contributor

Looks like this is implemented — I can mark it as such in swift-evolution. Would that be under Swift 4 or Swift 3.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants