Skip to content
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

Add CLI option to warn when a public decl has no intro version #25152

Merged
merged 1 commit into from Jun 17, 2019

Conversation

Projects
None yet
4 participants
@xymus
Copy link
Contributor

commented May 30, 2019

Add the command line option -require-explicit-availability to detect public or @usableFromInline declarations and warn if they don't declare an introduction OS version. This option should catch forgotten @available attributes in frameworks where all services are expected to be introduced by an OS version.

The option -require-explicit-availability-target "macOS 10.14, iOS 12.0" can be specified for the compiler to suggest fix-its with the missing attributes @available(macOS 10.14, iOS 12.0, *).

This is a similar check than #25104 warning of the same problem early on, but this option must be set by the developer.

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented May 30, 2019

@swift-ci please smoke test

@xymus xymus force-pushed the xymus:explicit-intro-version branch May 31, 2019

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented May 31, 2019

@swift-ci please smoke test

Show resolved Hide resolved lib/Sema/TypeCheckAvailability.cpp
Show resolved Hide resolved include/swift/Option/Options.td Outdated
lib/Sema/TypeCheckDecl.cpp Outdated
@@ -3140,6 +3149,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
}

TC.checkParameterAttributes(FD->getParameters());

validateExplicitIntroVersion(FD);

This comment has been minimized.

Copy link
@brentdax

brentdax Jun 8, 2019

Collaborator

You're inserting a lot of these calls. Is there somewhere else you could put them? Maybe checkAccessControl? (Don't take this as "definitely do it this way"; I don't know if there are calls to checkAccessControl that wouldn't want this check. Just seems like a code smell.)

This comment has been minimized.

Copy link
@xymus

xymus Jun 10, 2019

Author Contributor

I would like to have less call sites but I have yet to find another check that targets the same decls. Is there another file for this kind of check?

@xymus xymus force-pushed the xymus:explicit-intro-version branch 2 times, most recently Jun 10, 2019

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented Jun 10, 2019

@swift-ci Please smoke test

@xymus xymus force-pushed the xymus:explicit-intro-version branch 2 times, most recently Jun 12, 2019

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented Jun 12, 2019

@swift-ci Please smoke test

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented Jun 14, 2019

@swift-ci Please test source compatibility

Show resolved Hide resolved include/swift/Option/Options.td Outdated
Show resolved Hide resolved include/swift/Option/Options.td Outdated
Show resolved Hide resolved include/swift/Option/Options.td Outdated

@xymus xymus force-pushed the xymus:explicit-intro-version branch Jun 17, 2019

Add a CLI option to warn when a public decl has no availability
Add the command line option -require-explicit-availability to detect public
or `@usableFromInline` declarations and warn if they don't declare
an introduction OS version. This option should catch forgotten `@available`
attributes in frameworks where all services are expected to be introduced
by an OS version.

The option -require-explicit-availability-target "macOS 10.14, iOS 12.0"
can be specified for the compiler to suggest fix-its with the missing
attributes `@available(macOS 10.14, iOS 12.0, *)`.

rdar://51001662

@xymus xymus force-pushed the xymus:explicit-intro-version branch to c44cff7 Jun 17, 2019

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

@swift-ci Please smoke test

@xymus

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

@swift-ci Please test source compatibility

@xymus xymus merged commit 36e5b5a into apple:master Jun 17, 2019

4 checks passed

Swift Source Compatibility Suite on macOS Platform (Debug)
Details
Swift Source Compatibility Suite on macOS Platform (Release)
Details
Swift Test Linux Platform (smoke test)
Details
Swift Test OS X Platform (smoke test)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.