-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify diagnostics to suggest updating existing available attribute
- Loading branch information
1 parent
fc6011c
commit 438729b
Showing
11 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// RUN: %swift -typecheck -verify -parse-stdlib -module-name Swift -target x86_64-apple-macosx10.10 %s | ||
|
||
@available(SwiftStdlib 5.1, *) | ||
func FooForDefineAvailability() {} | ||
|
||
@available(SwiftStdlib 5.0, *) | ||
func FooForDefineAvailabilityTest() { | ||
FooForDefineAvailability() | ||
// expected-error@-1 {{'FooForDefineAvailability()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} | ||
|
||
@available(*, unavailable) | ||
func FooForUnavailable() {} // expected-note {{'FooForUnavailable()' has been explicitly marked unavailable here}} | ||
|
||
func FooForUnavailableTest() { | ||
FooForUnavailable() | ||
// expected-error@-1 {{'FooForUnavailable()' is unavailable}} | ||
} | ||
|
||
@available(macOS, introduced: 10.15) | ||
func FooForAvailability() {} | ||
|
||
@available(macOS, introduced: 10.10) | ||
func FooForAvailabilityTest() { | ||
// expected-note@-1 {{update @available attribute for macOS from 10.10 to 10.15 to meet the requirements of 'FooForAvailability'}} {{24:31-36=10.15}} | ||
FooForAvailability() | ||
// expected-error@-1 {{'FooForAvailability()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} | ||
|
||
@available(macOS 10.15, iOS 13, *) | ||
func FooForAvailability2() { | ||
} | ||
|
||
@available(macOS 10.10, *) | ||
func FooForAvailability2Test() { | ||
// expected-note@-1 {{update @available attribute for macOS from 10.10 to 10.15 to meet the requirements of 'FooForAvailability2'}} {{36:18-23=10.15}} | ||
FooForAvailability2() | ||
// expected-error@-1 {{'FooForAvailability2()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} | ||
|
||
@available(macOS 10.15, *) | ||
func FooForUnavailable2() {} | ||
|
||
@available(macOS, unavailable) | ||
func FooForUnavailable2Test() { | ||
FooForUnavailable2() | ||
// expected-error@-1 {{'FooForUnavailable2()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} | ||
|
||
@available(macOS 10.15, *) | ||
func FooForDeprecated() {} | ||
|
||
@available(macOS, deprecated: 12) | ||
func FooForDeprecatedTest() { | ||
FooForDeprecated() | ||
// expected-error@-1 {{'FooForDeprecated()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} | ||
|
||
@available(*, deprecated) | ||
func FooForDeprecatedTest2() { | ||
FooForDeprecated() | ||
// expected-error@-1 {{'FooForDeprecated()' is only available in macOS 10.15 or newer}} | ||
// expected-note@-2 {{add 'if #available' version check}} | ||
} |
Oops, something went wrong.