Skip to content

Commit fdc0ba2

Browse files
authored
Merge pull request #80411 from tshortli/skip-required-availability-checking-in-swiftinterfaces
Sema: Avoid diagnosing required availability in swiftinterface files
2 parents 3aa1ed1 + b6a425a commit fdc0ba2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Sema/TypeCheckAvailability.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -3456,6 +3456,12 @@ static bool declNeedsExplicitAvailability(const Decl *decl) {
34563456
if (!ctx.supportsVersionedAvailability())
34573457
return false;
34583458

3459+
// Don't enforce explicit availability requirements in .swiftinterface files.
3460+
// These diagnostics are only designed to be emitted when building from
3461+
// source.
3462+
if (decl->getDeclContext()->isInSwiftinterface())
3463+
return false;
3464+
34593465
// Skip non-public decls.
34603466
if (auto valueDecl = dyn_cast<const ValueDecl>(decl)) {
34613467
AccessScope scope =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// -require-explicit-availability is not printed in interfaces, so no warnings
2+
// should be emitted when verifying the interface.
3+
// RUN: %target-swift-emit-module-interface(%t_require.swiftinterface) -require-explicit-availability=warn %s
4+
// RUN: %target-swift-typecheck-module-from-interface(%t_require.swiftinterface) -verify
5+
6+
// -library-level=api implies -require-explicit-availability=warn and it _is_
7+
// printed in the interface. Still, no diagnostics about required explicit
8+
// availability should be emitted when verifying the interface.
9+
// RUN: %target-swift-emit-module-interface(%t_api.swiftinterface) -library-level=api %s
10+
// RUN: %target-swift-typecheck-module-from-interface(%t_api.swiftinterface) -verify
11+
12+
public struct NoAvailability { }

0 commit comments

Comments
 (0)