Skip to content

Commit 0136e19

Browse files
committed
Sema: Allow availability macros in embedded code
Availability macros are rejected from library-evolution inlinable code as the compiler didn't know how to print them in the swiftinterface. This isn't a concern with the embedded style of fragile functions, we can allow availability macros there.
1 parent 1b086e1 commit 0136e19

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5223,7 +5223,8 @@ static bool diagnoseAvailabilityCondition(PoundAvailableInfo *info,
52235223
// restriction, macros would need to either be expanded when printed in
52245224
// swiftinterfaces or be parsable as macros by module clients.
52255225
auto fragileKind = DC->getFragileFunctionKind();
5226-
if (fragileKind.kind != FragileFunctionKind::None) {
5226+
if (fragileKind.kind != FragileFunctionKind::None &&
5227+
fragileKind.kind != FragileFunctionKind::EmbeddedAlwaysEmitIntoClient) {
52275228
for (auto availSpec : info->getQueries()) {
52285229
if (availSpec->getMacroLoc().isValid()) {
52295230
diags.diagnose(availSpec->getMacroLoc(),

test/Sema/implementation-only-import-embedded.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// RUN: %target-swift-frontend -typecheck -verify %s -I %t \
1414
// RUN: -swift-version 5 -target arm64-apple-macosx15.0 \
15+
// RUN: -define-availability "availMacro:macOS 26.0, iOS 26.0" \
1516
// RUN: -enable-experimental-feature Embedded
1617

1718
// REQUIRES: swift_feature_Embedded
@@ -73,6 +74,8 @@ public func implicitlyInlinablePublic(arg: StructFromDirect = StructFromDirect()
7374
implicitlyInlinablePublic()
7475
implicitlyInlinablePrivate()
7576
explicitNonInliable()
77+
78+
if #available(availMacro, *) { }
7679
}
7780

7881
private func implicitlyInlinablePrivate(arg: StructFromDirect = StructFromDirect()) {

0 commit comments

Comments
 (0)