Skip to content

Sema: Avoid diagnosing required availability in swiftinterface files #80411

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3456,6 +3456,12 @@ static bool declNeedsExplicitAvailability(const Decl *decl) {
if (!ctx.supportsVersionedAvailability())
return false;

// Don't enforce explicit availability requirements in .swiftinterface files.
// These diagnostics are only designed to be emitted when building from
// source.
if (decl->getDeclContext()->isInSwiftinterface())
return false;

// Skip non-public decls.
if (auto valueDecl = dyn_cast<const ValueDecl>(decl)) {
AccessScope scope =
Expand Down
12 changes: 12 additions & 0 deletions test/ModuleInterface/require_explicit_availability.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// -require-explicit-availability is not printed in interfaces, so no warnings
// should be emitted when verifying the interface.
// RUN: %target-swift-emit-module-interface(%t_require.swiftinterface) -require-explicit-availability=warn %s
// RUN: %target-swift-typecheck-module-from-interface(%t_require.swiftinterface) -verify

// -library-level=api implies -require-explicit-availability=warn and it _is_
// printed in the interface. Still, no diagnostics about required explicit
// availability should be emitted when verifying the interface.
// RUN: %target-swift-emit-module-interface(%t_api.swiftinterface) -library-level=api %s
// RUN: %target-swift-typecheck-module-from-interface(%t_api.swiftinterface) -verify

public struct NoAvailability { }