Skip to content

Commit efab3ff

Browse files
committed
Parse: Broaden an availability spec diagnostic.
The "can't be combined with shorthand specification" diagnostic doesn't need to be specific to platform availability attributes.
1 parent 342dc1d commit efab3ff

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/Parse/ParseStmt.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,9 +1542,7 @@ Parser::parseAvailabilitySpecList(SmallVectorImpl<AvailabilitySpec *> &Specs,
15421542
// If this was preceded by a single platform version constraint, we
15431543
// can guess that the intention was to treat it as 'introduced' and
15441544
// suggest a fix-it to combine them.
1545-
if (Specs.size() == 1 &&
1546-
Previous->getPlatform() != PlatformKind::none &&
1547-
Text != "introduced") {
1545+
if (Specs.size() == 1 && Text != "introduced") {
15481546
auto PlatformNameEndLoc = Lexer::getLocForEndOfToken(
15491547
SourceManager, Previous->getStartLoc());
15501548

test/Parse/diagnose_availability.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func swiftDeprecatedObsoleted() {}
6464
// expected-warning@-1 {{expected 'introduced', 'deprecated', or 'obsoleted' in 'available' attribute for platform 'swift'}}
6565
func swiftMessage() {}
6666

67+
@available(swift 5, deprecated: 6)
68+
// expected-error@-1 {{'deprecated' can't be combined with shorthand specification 'swift 5'}}
69+
// expected-note@-2 {{did you mean to specify an introduction version?}} {{17-17=, introduced:}}
70+
// expected-error@-3 {{expected declaration}}
71+
func swiftShorthandFollowedByDeprecated() {}
72+
6773
@available(*, unavailable, message: "\("message")")
6874
// expected-error@-1{{'message' cannot be an interpolated string literal}}
6975
func interpolatedMessage() {}

0 commit comments

Comments
 (0)