Commit Graph

21 Commits

Author SHA1 Message Date
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Ben Langmuir
c957826c28 [sema] Fix availability narrowing fixits for macOS >= 11
For macOS >= 11 the fixit for narrowing an availability check rather
than adding a new one should fire if the major version is the same, like
on other platforms.
2024-08-21 10:22:07 -07:00
Mishal Shah
10dda582d6 [Apple Silicon] Update tests for no macOS target triple canonicalization
LLVM no longer canonicalizes target triples for maOS versions. Update
tests to account for this.
2020-07-02 19:30:01 -07:00
Brent Royal-Gordon
3494c0bd88 [TypeChecker] Rephrase platforms in availability diagnostics
This does several different things to improve how platforms are described in availability diagnostics:

• Mentions the platform in diagnostics for platform-specific @available(unavailable) attributes.
• Replaces “OS X” with “macOS”.
• Replaces “fooOS application extension” with “application extensions for fooOS”.
• Replaces “on fooOS” with “in fooOS”.

Fixes <rdar://problem/49963341>.
2019-04-30 16:32:43 -07:00
Slava Pestov
336f51e5bc Sema: Fix availability of inherited designated initializers, part 2
We need to explicitly handle nested types here.

Fixes the (re-opened) <rdar://problem/40853731>,
<https://bugs.swift.org/browse/SR-7881>.
2018-07-24 16:13:45 -07:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Trent Nadeau
0cc851568a Updated tests to use @discardableResult and _ = . 2016-05-11 22:53:38 -04:00
Daniel Duan
7cabf3555b [Parser] update test for SE-0040 changes 2016-03-11 16:01:37 -08:00
Slava Pestov
79b24fa7d1 Update availability tests to be independent of the actual deployment target
Use fictional version numbers in the 10.50..10.99 range.
2016-01-13 19:27:26 -08:00
Devin Coughlin
550b9feb05 [Sema] Improve clarity of fix-it hint to add #available.
As suggested by Jordan, change "add if #available version check" to
"add 'if #available' version check" to make it easier to read.

Swift SVN r29650
2015-06-25 01:03:50 +00:00
Devin Coughlin
5a71aaef6c [Sema] Update availability fix-it to be consistent.
Change the fix-it suggesting adding #available to be consistent with the fix-it
adding @available.

This changes "guard with version check" to "add if #available version check".

rdar://problem/21275857

Swift SVN r29648
2015-06-25 00:23:02 +00:00
Devin Coughlin
8e071b1148 Revert "[Sema] Suppress warning about useless availability checks in playgrounds and script mode."
As Jordan notes, this uses the wrong check: isScriptMode() is also true for
main.swift in an app or command-line tool.

This reverts commit 8a72f4357bc04a386cf82acd1de06896515ab5a8.

Swift SVN r29583
2015-06-23 23:39:44 +00:00
Devin Coughlin
200b55be70 [Sema] Suppress warning about useless availability checks in playgrounds and script mode.
We normally report a warning when a #available() check will always be true
because of the minimum deployment target. These warnings are potentially
annoying when the developer either cannot change the minimum deployment target
from the default (as in playgrounds) or when doing so is burdensome (as for
command-line scripts, which would require passing a target triple) -- so
suppress them.

rdar://problem/21324005

Swift SVN r29582
2015-06-23 23:31:12 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Chris Lattner
4366da9250 more testcase updates for upcoming diagnostics change.
Swift SVN r28409
2015-05-11 06:05:00 +00:00
Devin Coughlin
d08b98b1ca Sema: Turn on availability checking by default
Enable checking for uses of potentially unavailable APIs. There is
a frontend option to disable it: -disable-availability-checking.

This commit updates the SDK overlays with @availability() annotations for the
declarations where the overlay refers to potentially unavailable APIs. It also changes
several tests that refer to potentially unavailable APIs to use either #available()
or @availability annotations.

Swift SVN r27272
2015-04-14 06:44:01 +00:00
Devin Coughlin
e6344938c3 Sema: Disallow potential unavailability on script-mode globals
In source files that are in script mode, global variable initialization
expressions are eagerly executed. For this reason, disallow @availability
attributes having 'introduced=' on script-mode globals.

I had to rejigger a fair number of potential unavailability tests because they
weren't written with this distinction in mind.

Swift SVN r27137
2015-04-08 21:29:14 +00:00
Devin Coughlin
d5f3e879e6 Sema: Tweak availability and deprecation diagnostic text
Minor tweaks to availability diagnostic text based on feedback from Chris, Ted, and Doug.
This changees "'foo' is only available on OS X version 10.10 or greater" to
"'foo' is only available on OS X 10.10 or newer".

This change also updates the deprecation and obsoleted diagnostics to be consistent with
the new text.

Swift SVN r26344
2015-03-20 01:36:20 +00:00
Devin Coughlin
749f8500d6 Sema: Emit Fix-Its for potential unavailability
We now suggest up to three Fix-Its for each reference to a potentially
unavailable symbol: one to wrap the reference in an if #os(...) { ... }
guard (if possible), one to add an @availability attribute to an enclosing
property or method (if possible), and one to add an @availability attribute
to an enclosing class/struct/extension, etc. or global function.

The goal here is not to infer the "best" Fix-It but rather to ensure
discoverability of #os() and @availability attributes. We want the user, when
faced with an availability diagnostic, to be aware of the tools in her toolbox
to deal with it.

This is still missing QoI improvements, including Fix-Its to update
existing @availability attributes and more precise wording in diagnostics
(e.g, "initializer" instead of function, "class" instead of "type"). These
improvements will come in later commits.

Swift SVN r26073
2015-03-12 23:51:11 +00:00
Devin Coughlin
6b5a3d775e [Sema]Construct type refinement hierarchy for other source files
Resolving signatures of declarations from files other than the primary source
file causes first-pass type checking, including diagnostics for potential
unavailability, to be performed on those declarations. Prior to this commit, the
type refinement context hierarchy was only constructed for the primary file, so
spurious errors were emitted when checking declarations in other files. With
this commit, the availability checker builds the hierarchy for a source file the
first time its hierarchy is queried. We will eventually want to build the
hierarchy more lazily, but that will come later.

Swift SVN r25746
2015-03-04 05:36:48 +00:00