Skip to content

Commit cfdcbc7

Browse files
committed
Sema: Only warn about @inlinable implying @usableFromInline in -swift-version 4.2
Another SwiftNIO request. Fixes <https://bugs.swift.org/browse/SR-7578>.
1 parent 07db1f0 commit cfdcbc7

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,8 @@ void AttributeChecker::visitUsableFromInlineAttr(UsableFromInlineAttr *attr) {
19821982

19831983
// On internal declarations, @inlinable implies @usableFromInline.
19841984
if (VD->getAttrs().hasAttribute<InlinableAttr>()) {
1985-
diagnoseAndRemoveAttr(attr, diag::inlinable_implies_usable_from_inline);
1985+
if (TC.Context.isSwiftVersionAtLeast(4,2))
1986+
diagnoseAndRemoveAttr(attr, diag::inlinable_implies_usable_from_inline);
19861987
return;
19871988
}
19881989
}

test/Compatibility/attr_inlinable_old_spelling_4.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55

66
@_inlineable public func oldInlinableFunction() {}
77
@_versioned func oldVersionedFunction() {}
8+
9+
// No warning here
10+
@_inlineable @_versioned func redundantAttribute() {}

test/Compatibility/attr_inlinable_old_spelling_42.swift

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

88
@_versioned func oldVersionedFunction() {}
99
// expected-warning@-1 {{'@_versioned' has been renamed to '@usableFromInline'}}{{2-12=usableFromInline}}
10+
11+
@inlinable @usableFromInline func redundantAttribute() {}
12+
// expected-warning@-1 {{'@inlinable' declaration is already '@usableFromInline'}}

test/attr/attr_inlinable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-typecheck-verify-swift -swift-version 4
2-
// RUN: %target-typecheck-verify-swift -swift-version 4 -enable-testing
3-
// RUN: %target-typecheck-verify-swift -swift-version 4 -enable-resilience
4-
// RUN: %target-typecheck-verify-swift -swift-version 4 -enable-resilience -enable-testing
1+
// RUN: %target-typecheck-verify-swift -swift-version 4.2
2+
// RUN: %target-typecheck-verify-swift -swift-version 4.2 -enable-testing
3+
// RUN: %target-typecheck-verify-swift -swift-version 4.2 -enable-resilience
4+
// RUN: %target-typecheck-verify-swift -swift-version 4.2 -enable-resilience -enable-testing
55
@inlinable struct TestInlinableStruct {}
66
// expected-error@-1 {{'@inlinable' attribute cannot be applied to this declaration}}
77

0 commit comments

Comments
 (0)