Skip to content
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
15 changes: 5 additions & 10 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4391,21 +4391,16 @@ void AttributeChecker::checkBackDeployAttrs(ArrayRef<BackDeployAttr *> Attrs) {
if (Attrs.empty())
return;

// Diagnose conflicting attributes. @_alwaysEmitIntoClient, @inlinable, and
// @_transparent all conflict with back deployment because they each cause the
// body of a function to be copied into the client under certain conditions
// and would defeat the goal of back deployment, which is to always use the
// ABI version of the declaration when it is available.
// Diagnose conflicting attributes. @_alwaysEmitIntoClient and @_transparent
// conflict with back deployment because they each cause the body of a
// function to always be copied into the client and would defeat the goal of
// back deployment, which is to use the ABI version of the declaration when it
// is available.
if (auto *AEICA = D->getAttrs().getAttribute<AlwaysEmitIntoClientAttr>()) {
diagnoseAndRemoveAttr(AEICA, diag::attr_incompatible_with_back_deploy,
AEICA, D->getDescriptiveKind());
}

if (auto *IA = D->getAttrs().getAttribute<InlinableAttr>()) {
diagnoseAndRemoveAttr(IA, diag::attr_incompatible_with_back_deploy, IA,
D->getDescriptiveKind());
}

if (auto *TA = D->getAttrs().getAttribute<TransparentAttr>()) {
diagnoseAndRemoveAttr(TA, diag::attr_incompatible_with_back_deploy, TA,
D->getDescriptiveKind());
Expand Down
2 changes: 2 additions & 0 deletions test/attr/Inputs/BackDeployHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ extension IntArray {

@available(BackDeploy 1.0, *)
@_backDeploy(before: BackDeploy 2.0)
@inlinable
public subscript(_ i: Int) -> Int {
get { _values[i] }
_modify { yield &_values[i] }
Expand Down Expand Up @@ -180,6 +181,7 @@ extension ReferenceIntArray {

@available(BackDeploy 1.0, *)
@_backDeploy(before: BackDeploy 2.0)
@inlinable
public final subscript(_ i: Int) -> Int {
get { _values[i] }
_modify { yield &_values[i] }
Expand Down
2 changes: 1 addition & 1 deletion test/attr/attr_backDeploy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public func alwaysEmitIntoClientFunc() {}

@available(macOS 11.0, *)
@_backDeploy(before: macOS 12.0)
@inlinable // expected-error {{'@inlinable' cannot be applied to a back deployed global function}}
@inlinable // OK
public func inlinableFunc() {}

@available(macOS 11.0, *)
Expand Down