@@ -1536,35 +1536,34 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
1536
1536
// If the attribute follows the new representation, switch
1537
1537
// over to the alternate parsing path.
1538
1538
DeclAttrKind DK = DeclAttribute::getAttrKindFromString (Tok.getText ());
1539
-
1540
- auto checkRenamedAttr = [&](StringRef oldName , StringRef newName ,
1541
- DeclAttrKind kind, bool warning ) {
1542
- if (DK == DAK_Count && Tok.getText () == oldName ) {
1539
+
1540
+ auto checkInvalidAttrName = [&](StringRef invalidName , StringRef correctName ,
1541
+ DeclAttrKind kind, Diag<StringRef, StringRef> diag ) {
1542
+ if (DK == DAK_Count && Tok.getText () == invalidName ) {
1543
1543
// We renamed @availability to @available, so if we see the former,
1544
1544
// treat it as the latter and emit a Fix-It.
1545
1545
DK = kind;
1546
- if (warning) {
1547
- diagnose (Tok, diag::attr_renamed_warning, oldName, newName)
1548
- .fixItReplace (Tok.getLoc (), newName);
1549
- } else {
1550
- diagnose (Tok, diag::attr_renamed, oldName, newName)
1551
- .fixItReplace (Tok.getLoc (), newName);
1552
- }
1546
+
1547
+ diagnose (Tok, diag, invalidName, correctName)
1548
+ .fixItReplace (Tok.getLoc (), correctName);
1553
1549
}
1554
1550
};
1555
1551
1556
1552
// FIXME: This renaming happened before Swift 3, we can probably remove
1557
1553
// the specific fallback path at some point.
1558
- checkRenamedAttr (" availability" , " available" , DAK_Available, false );
1554
+ checkInvalidAttrName (" availability" , " available" , DAK_Available, diag::attr_renamed);
1555
+
1556
+ // Check if attr is inlineable, and suggest inlinable instead
1557
+ checkInvalidAttrName (" inlineable" , " inlinable" , DAK_Inlinable, diag::attr_name_close_match);
1559
1558
1560
1559
// In Swift 5 and above, these become hard errors. Otherwise, emit a
1561
1560
// warning for compatibility.
1562
1561
if (!Context.isSwiftVersionAtLeast (5 )) {
1563
- checkRenamedAttr (" _versioned" , " usableFromInline" , DAK_UsableFromInline, true );
1564
- checkRenamedAttr (" _inlineable" , " inlinable" , DAK_Inlinable, true );
1562
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed_warning );
1563
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed_warning );
1565
1564
} else {
1566
- checkRenamedAttr (" _versioned" , " usableFromInline" , DAK_UsableFromInline, false );
1567
- checkRenamedAttr (" _inlineable" , " inlinable" , DAK_Inlinable, false );
1565
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed );
1566
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed );
1568
1567
}
1569
1568
1570
1569
if (DK == DAK_Count && Tok.getText () == " warn_unused_result" ) {
0 commit comments