Skip to content

Commit b68775c

Browse files
committed
Shop the Wording of @usableFromInline Redundancy Diagnostic
- Explicitly call out the decl kind - Clearly state the exact issue at hand - Correct the tests to check for the fixit rdar://88527799
1 parent abd0582 commit b68775c

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5670,7 +5670,8 @@ ERROR(usable_from_inline_attr_with_explicit_access,
56705670
(DeclName, AccessLevel))
56715671

56725672
WARNING(inlinable_implies_usable_from_inline,none,
5673-
"'@inlinable' declaration is already '@usableFromInline'",())
5673+
"'@usableFromInline' attribute has no effect on '@inlinable' %0 %1",
5674+
(DescriptiveDeclKind, DeclName))
56745675

56755676
ERROR(usable_from_inline_attr_in_protocol,none,
56765677
"'@usableFromInline' attribute cannot be used in protocols", ())

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,8 @@ void AttributeChecker::visitUsableFromInlineAttr(UsableFromInlineAttr *attr) {
24142414
// On internal declarations, @inlinable implies @usableFromInline.
24152415
if (VD->getAttrs().hasAttribute<InlinableAttr>()) {
24162416
if (Ctx.isSwiftVersionAtLeast(4,2))
2417-
diagnoseAndRemoveAttr(attr, diag::inlinable_implies_usable_from_inline);
2417+
diagnoseAndRemoveAttr(attr, diag::inlinable_implies_usable_from_inline,
2418+
VD->getDescriptiveKind(), VD->getName());
24182419
return;
24192420
}
24202421
}

test/Compatibility/attr_inlinable_old_spelling_42.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
// expected-warning@-1 {{'@_versioned' has been renamed to '@usableFromInline'}}{{2-12=usableFromInline}}
1010

1111
@inlinable @usableFromInline func redundantAttribute() {}
12-
// expected-warning@-1 {{'@inlinable' declaration is already '@usableFromInline'}}
12+
// expected-warning@-1 {{'@usableFromInline' attribute has no effect on '@inlinable' global function 'redundantAttribute()'}}

test/attr/attr_inlinable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// expected-error@-1 {{'@inlinable' attribute cannot be applied to this declaration}}
77

88
@inlinable @usableFromInline func redundantAttribute() {}
9-
// expected-warning@-1 {{'@inlinable' declaration is already '@usableFromInline'}}
9+
// expected-warning@-1 {{'@usableFromInline' attribute has no effect on '@inlinable' global function 'redundantAttribute()'}} {{12-30=}}
1010

1111
private func privateFunction() {}
1212
// expected-note@-1 2{{global function 'privateFunction()' is not '@usableFromInline' or public}}

0 commit comments

Comments
 (0)