Commit Graph

28382 Commits

Author SHA1 Message Date
Allan Shortlidge
56f7ffd26c Merge pull request #79858 from tshortli/spi-available-attr-diagnostics
Sema: Diagnose `@_spi_available` on declarations that cannot be unavailable
2025-03-08 03:48:56 -08:00
Hamish Knight
a596f23fbf Merge pull request #79850 from hamishknight/key-hack
[Sema] Apply CodingKeys hack to `TypeChecker::lookupUnqualifiedType`
2025-03-08 10:35:16 +00:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Allan Shortlidge
0fd2f3fc1c Sema: Diagnose @_spi_available on declarations that cannot be unavailable.
The attribute makes the declaration unavailable from the perspective of clients
of the module's public interface and was creating a loophole that admitted
inappropriate unavailability.
2025-03-07 19:44:48 -08:00
Allan Shortlidge
396e8f033b Merge pull request #79849 from tshortli/allow-unavailable-proto-requirements-in-swiftinterface
Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces
2025-03-07 18:02:26 -08:00
Allan Shortlidge
4276771252 Sema: Consolidate diagnostics for decls that cannot be unavailable. 2025-03-07 17:43:51 -08:00
Evan Wilde
28f96411c9 Merge pull request #79778 from etcwilde/ewilde/yo-dawg-heard-you-liked-swift
CMake: option to disable swift in swift
2025-03-07 13:12:00 -08:00
Hamish Knight
7ae3ccf0bf [Sema] Apply CodingKeys hack to TypeChecker::lookupUnqualifiedType
Currently we handle CodingKeys synthesis in
`TypeChecker::lookupUnqualified`, make sure we do the same in
`TypeChecker::lookupUnqualifiedType`.

rdar://146055457
2025-03-07 21:03:33 +00:00
Allan Shortlidge
6284dd4895 Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces.
Historically, we've allowed protocol requirements to be written with
`@_spi_available` which makes them unavailable to clients of the public
`.swiftinterface`. Don't diagnose this when checking a `.swiftinterface` since
there's nothing the client can do about it.

Resolves rdar://146334181.
2025-03-07 12:02:42 -08:00
Anthony Latsis
5d92f7953c Merge pull request #79792 from AnthonyLatsis/danaus-plexippus-2
Introduce adoption mode for Swift features (take 2)
2025-03-07 19:47:44 +00:00
nate-chandler
38c8cc8ff4 Merge pull request #77661 from nate-chandler/general-coro/20241115/1
[CoroutineAccessors] Default implementations are transparent.
2025-03-07 11:39:21 -08:00
Pavel Yaskevich
87e3e3d8a1 [CSBindings] Don't delay inferred loeading-dot base inference if source is a contextual type
Transitively inferring a protocol type binding from a contextual
type means that the binding set for a leading-dot member reference
is complete because there could be no other sources of bindings
when expression is connected directly to a contextual type.

Resolves: rdar://145103149
2025-03-06 14:58:21 -08:00
Doug Gregor
0ec13f9a90 Build compiler and runtimes without Swift
Remove dependency on macros from compiler and stdlib build when
bootstrapping the compiler without Swift available.
2025-03-06 13:32:52 -08:00
Allan Shortlidge
6ab32cff94 Sema: Parameterize potential unavailability diagnostics to allow no version.
This allows `X is only available in` diagnostics to be emitted for potential
unavailability in domains that do not support versioning.
2025-03-06 13:04:18 -08:00
Allan Shortlidge
0bf464b272 AST: Return optional AvailabilityRange from SemanticAvailableAttr queries.
Introduction, deprecation, and obsoleteion ranges should only be returned by
the accessors on `SemanticAvailableAttr` when the attribute actually has an
affect on the corresponding kind of availability.
2025-03-06 13:02:19 -08:00
Hamish Knight
cc145482de Merge pull request #79759 from jameesbrown/bool-literal-case
[TypeChecker] Simplify ExprPattern from Bool literals in Bool? switch
2025-03-06 18:09:08 +00:00
Allan Shortlidge
77d18a87ea Merge pull request #79784 from tshortli/optimize-version-range-layout
AST: Optimize the layout of `AvailabilityRange`
2025-03-05 12:10:29 -08:00
Pavel Yaskevich
4a646b43f1 Merge pull request #79776 from xedin/fix-recording-of-opened-pack-expansions-in-trail
[CSSolver] Properly record opened pack expansion types
2025-03-05 09:03:23 -08:00
Anthony Latsis
6a3903bb53 Revert "Revert "Introduce adoption mode for Swift features""
This reverts commit 393c59c078.
2025-03-05 15:21:01 +00:00
Allan Shortlidge
cad1ee75d5 AST: Optimize the layout of AvailabilityRange.
`AvailabilityRange` is now being used as a currency type in more of the
compiler, and some of those uses are in permanent `ASTContext` allocations. The
class wraps the `VersionRange` utility, which is itself a wrapper around
`llvm::VersionTuple` with some additional storage for representing sentinel
values. Even though the two sentinel values can be be represented with just a
single bit of additional storage on top of the 16 bytes required to represent
`VersionTuple`, because of alignment requirements the sentinel values end up
bloating the layout of `VersionRange` by many bytes.

To make `AvailabilityRange` and `VersionRange` more efficient to store, we can
instead reserve two unlikely `llvm::VersionTuple` bit patterns as the sentinel
values instead. The values chosen are the same ones LLVM uses to represent
version tuple tombstones and empty keys in a `DenseMap`.
2025-03-05 07:15:15 -08:00
James Brown
3649dcbf04 [TypeChecker] Bool literals in switch
Bool literals are regarded as expr patterns when
switching over Optional<Bool>. Simplify the expr
by converting to their optional counterparts.
2025-03-05 09:33:24 -05:00
Allan Shortlidge
6eab842e7a Merge pull request #79777 from tshortli/potential-unavailability-diagnostics
AST/Sema: Decouple potential unavailability diagnostics from platform version
2025-03-05 00:35:23 -08:00
Allan Shortlidge
fe0688c40e Sema: Update diagnostics to take AvailabilityRange instead of VersionTuple. 2025-03-04 19:41:04 -08:00
Allan Shortlidge
b64df7384e AST: Simplify AvailabilityRange construction.
Introduce a constructor that takes an `llvm::VersionTuple` directly, instead of
needing to spell out `VersionRange::allGTE(<tuple>)` which is unnecessarily
verbose.
2025-03-04 19:41:04 -08:00
Allan Shortlidge
cb778b7ce4 AST/Sema: Expand potential unavailability diagnostics to arbitrary domains.
When emitting potential unavailability diagnostics, don't assume that they can
only apply to the target platform `AvailabilityDomain`.
2025-03-04 19:41:04 -08:00
Rintaro Ishizaki
393c59c078 Revert "Introduce adoption mode for Swift features" 2025-03-04 19:13:05 -08:00
Anthony Latsis
43b00af490 Merge pull request #79649 from AnthonyLatsis/danaus-plexippus
Introduce adoption mode for Swift features
2025-03-04 23:16:28 +00:00
Pavel Yaskevich
effc468f99 [CSSolver] Properly record opened pack expansion types
This bug leads to accumulation of data in the constraint
system even though most of it is out of scope.
2025-03-04 14:48:02 -08:00
Artem Chikin
6da529f098 Merge pull request #79753 from artemcm/NewConstFeatureDefinition
[Compile Time Values] Add a new experimental feature and the parsing of the `@const` attribute
2025-03-04 12:26:04 -08:00
Pavel Yaskevich
157e71a791 Merge pull request #79478 from xedin/sendable-completion-handler-fixes
[TypeChecker/NameLookup] SE-0463: A few fixes for `SendableCompletionHandlers` feature
2025-03-04 09:34:10 -08:00
Pavel Yaskevich
eb7b76525c Merge pull request #79651 from xedin/sendability-checks-for-function-conversions
[Concurrency] Implement sendability checking for `@Sendable` function…
2025-03-04 09:33:59 -08:00
Doug Gregor
c169f8850b Merge pull request #79760 from DougGregor/isolated-conformances-checking
Ensure that isolated conformances originate in the same isolation domain
2025-03-04 07:49:53 -08:00
Artem Chikin
13a8d4b88e [Compile Time Values] Add a new experimental feature and the parsing of the '@const' attribute 2025-03-04 07:30:57 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Anthony Latsis
1fc853141f Sema: Implement adoption mode for ExistentialAny 2025-03-04 13:43:28 +00:00
Anthony Latsis
2771f36ced LangOptions: Refactor feature state and API to account for adoption mode 2025-03-04 13:43:28 +00:00
Doug Gregor
5c67cffbc0 Prevent infinite recursion with conformance enumeration. 2025-03-03 22:14:54 -08:00
Holly Borla
8be41edf6f [Concurrency] Add a macro for wrapping a function body in a new task. 2025-03-03 20:51:14 -08:00
Doug Gregor
064e0c6264 Ensure that isolated conformances originate in the same isolation domain
This is the missing check for "rule #1" in the isolated conformances proposal,
which states that an isolated conformance can only be referenced within
the same isolation domain as the conformance. For example, a
main-actor-isolated conformance can only be used within main-actor code.
2025-03-03 17:47:50 -08:00
Pavel Yaskevich
156a43d162 [Concurrency] Make sure that conversion that switches from one actor to another is not accepted 2025-03-03 15:23:34 -08:00
Pavel Yaskevich
23739ef9af [Concurrency] Converting from @execution(concurrent) to actor-isolated crosses an isolation boundary 2025-03-03 14:42:09 -08:00
Pavel Yaskevich
1a42c153b8 [Concurrency] Converting from nonisolated to @execution(caller) does not cross an isolation boundary 2025-03-03 14:25:11 -08:00
Allan Shortlidge
dc2fe53089 AST: Rename a couple of AvailabilityConstraint::Reason cases.
Choose names that don't imply availability is versioned, since custom
availability will support domains that are version-less (they are simply
available or unavailable).
2025-03-02 15:08:37 -08:00
Allan Shortlidge
dc3df46dd5 Merge pull request #79730 from tshortli/availability-comparisons
AST: Consolidate availability version remapping
2025-03-02 14:41:57 -08:00
Allan Shortlidge
3b9ca2f397 AST: Consolidate availability version remapping.
Introduce `SemanticAvailableAttr` conveniences to compute the deprecated and
obsoleted ranges for an attribute and ensure they remap versions when needed.
2025-03-01 20:23:11 -08:00
Doug Gregor
ee2450f212 Merge pull request #79724 from DougGregor/isolated-conformances-constraint-system
Prohibit isolated conformances with Sendable(Metatype) constraints
2025-03-01 13:16:32 -08:00
Doug Gregor
6a4d1a41c4 Prohibit isolated conformances with Sendable(Metatype) constraints
Within the constraint system, introduce a new kind of conformance constraint,
a "nonisolated conforms-to" constraint, which can only be satisfied by
nonisolated conformances. Introduce this constraint instead of the normal
conforms-to constraint whenever the subject type is a type parameter that
has either a `Sendable` or `SendableMetatype` constraint, i.e., when the type
or its values can escape the current isolation domain.
2025-03-01 08:19:42 -08:00
Allan Shortlidge
309db1c220 Sema: Update feature availability diagnostics to take AvailabilityDomain. 2025-02-28 14:46:34 -08:00
Allan Shortlidge
bc982097b9 AST/Sema: Adopt AvailabilityDomain arguments in even more diagnostics.
Update potential unavailability diagnostics to take `AvailabilityDomain`
instead of a platform string.
2025-02-28 14:13:24 -08:00
Allan Shortlidge
c89df2fc38 AST/Sema: Adopt AvailabilityDomain arguments in more diagnostics.
Update explicit unavailability and deprecation diagnostics to take
`AvailabiiltyDomain` instead of a platform string.
2025-02-28 13:57:00 -08:00